I wish basically to store my pages or product long descriptions in txt or html files in folders, not in database.
Is there any simple and easy way to do so, instead of iframe which does not work quite well and does not even display the content in the page code so it is not indexed by search engines as it should.
I've read about web components html imports but that seem to be so much complicated and does not really satisfy my needs.
I have not found any plugin to do so, maybe there is one.
I know I wish to make wordpress flat file cms, but maybe there is some new easy way to simply insert pages from anywhere but database might be via shortcode or just an url.
I put it in tags, should say more clear, it is about wordpress on host. As it stores all pages and data in database and I realized bigger database is slower it works. I use caching plugin but I also wish to speed up admin panel and dynamic uncacheble content. My idea is to slim down the database as much as possible and in my woocommerce store most of the data is long description. So the best way would be to inject the long description via shortcode that would take html content from anywhere else but database. I need html, not just some text to insert. This way I would cache these product pages anyway but the database would stay way slimmer and all the dynamic content would go way faster.
In PHP you can use the function file_get_contents, which will display the contents of a file (but not parse it as PHP, which is more secure for obvious reasons).
So you could try something like this if you wanted to account for a page not found message:
function example_get_content($file_url){
if(file_exists($file_url)){
return file_get_contents($file_url);
}
else{
return 'Sorry, this page could not be found'
}
}
And then in your template use
echo example_get_content('http://example.com/my_text_file.txt');
Related
I'm a Wordpress virgin, thrown into something I don't know much about, just trying to help. I do know a few things about php.
I would like to know if somehow in wordpress (not via an update vulnerable hack) it is possible to see and manipulate the full page content, before it is displayed ?
I would like to check a few things in the page meta-data tags, cross reference that with data in the body on various places, make a few changes here and there if needed and THEN hand it over to Wordpress again.
Some sort of callback, at the last moment, with the full page's content in a php variable.
Maybe this is simply not possible ?
Hope to learn something. Cheers.
I'm just trying to move one of my old php sites to wordpress. As part of the site I have 'top tables' e.g. top 10 cars, listing their features etc. At the moment that all comes from a database and the HTML is generated from the data.
So if a car soon gets a hybrid engine I just check that in the database and my web site table updates to reflect that.
This all works fine. I just don't know where to start when trying to implement something like this in wordpress. I want to keep the WP header, footer, nav... and put my table in to the content area.
Someone recommended simply copying the current generated HTML in to a new post and editing the HTML when anything changes, this sounds like a quick solution but there must be a better way of doing this.
Ideally I would want to keep my current data input pages (and separate database) for all of this 'table data' and present the out put as a post.
If anyone can point me in the right direction (key words I should search for, a guide) that would be great.
Depending on your usecase, you'll usually want to use a static page template:
http://codex.wordpress.org/Page_Templates
Or shortcodes:
http://codex.wordpress.org/Shortcode_API
Is it possible to link to a page that doesn't necessarily exists as drupal content and not get a 404 page not found.
Example:
link: example.com/search/projects?content="words"
There is no search/projects node or page so obviously it returns page not found although I can still run my queries inside that page.
Views would probably be a solution here but I sort of need more control on the outputted html and don't feel like going in to the views templates.
I guess my question is if it is possible to mimic views feature of creating pages which will aggregate content but don't have content theme selfs.
Is this possible at all? It seems pretty standard right? I have no idea ho to do it thought...
You can create a menu item for search/projects and return anything you'd like.
http://api.drupal.org/api/drupal/developer%21hooks%21core.php/function/hook_menu/6
should get you started.
I created a "View"* in Drupal to grab all the content and essentially make a site map, but I realized that it doesn't have an option to grab content from the Blocks I have created. Does anyone have an idea if I can even do that?
If not, should I essentially make each block a page so that it can crawl through the pages? I worry that this will end up becoming unmanageable in the end... What are some other options/work arounds? My end goal is to make a site map - maybe I am making this too complicated?
*To make my view I did:
Administration->Structure->Views->Add. Then I made it a page, called it "site-index", and made it "show Content of type All" (with tagged field empty). Then I chose "Content: Title" for my Fields and my Filter Criteria is set as: "Content: Published (Yes):" - That way, it will grab the titles of my web pages.
Thanks, and please reply if further clarification is needed!
Apologies if I'm wrong but I think there might be a bit of confusion over terminology here. In the context of a view Content means nodes, not all HTML content on the site. Your view will return a list of all published nodes, which are essentially the pages on your site.
On a normal sitemap (if there is such a thing) you would only link to full pages, not to parts of pages like a block, they are essentially used to provide a hierarchical overview of your site to aid navigation for users and, probably more importantly these days, search engines (you can submit an XML sitemap to the major search engines instead of this but that's really for another question).
Rather than doing this yourself I'd actually recommend you download and install the Sitemap module which will do all of the work for you, as well as arranging the content in their respective hierarchy.
The task is relatively straightforward:
A Drupal website displays a list of articles with thumbnails. Some visitors would like to view it without images by clicking on a button/link and have that preference saved.
e.g. http://patterntap.com/collections/index/
The problem is all visitors are anonymous and given certain traffic, page cache is enabled.
My idea was to use some simple JavaScript to set a cookie, refresh the page and depending on the cookie values (or its presence/absence) display or hide the images.
Except Drupal serves cached pages quite early and the only quick way to modify the cached version that I could find is by hacking includes/bootstrap.inc and add a custom class to the body classes then hide the images with css.
A very wrong approach, I know. But I wonder if there is a way to save different versions of a page and serve the correct version?
Edit:
need to keep the same uri
the js to show/hide the images without reload and set the cookie is already in place
hook_boot() is not really called for cached pages, so can't do it via custom module
.htaccess mods?
Edit/solution:
In the end went with Rimian's suggestion. But it is possible to accomplish the task using our own cache.inc implementation as seen in the Mobile Tools module. Specifically, by extending cache.inc and updating settings.php to include
$conf['page_cache_fastpath'] = FALSE;
$conf['cache_inc'] = 'path/to/my/module/my_module_cache.inc';
So let me get this right. You wanna hide some images on a cached page if the user chooses to?
Why don't you write some jQuery or javascript and load that into your cached page with all the rest of the document?
Then, the client/browser would decide to run your script and hide images depending on some parameters you passed along with the request to that page or in the cookie? The script gets cached and only runs when you call it.
If you were hacking the bootstrap for something like that you'd really need to be rethinking what you were doing. Crazy! :)
Also take a look at cache_get and cache_set:
http://api.drupal.org/api/drupal/includes--cache.inc/6
I'm not sure I 100% understand what you are trying to do but here are my thoughts. One of your root problems is that you are trying to access what is essentially different content at the same uri.
If this is truly what you want to do, then Rimian's suggestion of checking out chache_get and chache_set may be worthwhile.
Personally, it seems cleaner to me to have your "with thumbnails" and "without thumbnails" be accessed via different uri's. Depending on exactly what you are wanting to accomplish, a GET variable my be an even better way to go. With either of these two options you would hide or show your thumbnails at the theme layer. Pages with different paths or get variables would get cached separately.
If you want the visitor to be able to switch views without a page reload, then jQuery and a cookie would probably suite your needs. This wouldn't require a page reload and switching back and forth would be quite simple.