Drupal 6 custom page templates fighting each other - drupal

I have a page template: page-lcds.tpl.php which works for the www.xxx.com/lcds page.
But, it also gets used for /lcds/2-4in and /lcds/5-10in and etc.
So I could create a page-lcds-2-4in.tpl.php but then I'd have to create all the others for each category.
All of these pages are actual custom Pages content-type.
Is there a better way/place to specify a page template just for "page-lcds" and then use the regular page.tpl.php file for all other lcds/*?

I think, you should treat LCD as category instead of content type.
So, create a vocabulary called "Product type" & add "LCD","LED" terms to it.
Now, you can do category theming under page-taxonomy-term.tpl.php
and node theming under page-node-<custom-content-type>.tpl.php

Related

How to create subpages for taxonomy term page in wordpress?

I have created a custom taxonomy and what the term page will look like.
domain.com/taxonomy/term
But for each taxonomy term, I have included various custom fields and included content. The content is large and I want to display them in subpages with individual link clicks. I want to display them in subpages.
For eg:
domain.com/taxonomy/term/meta-data-1
domain.com/taxonomy/term/meta-data-2
How can I create this?
I am using Genesis Framework
I'm assuming you have some knowledge in php and Wordpress theming.
You could create/add a custom-subterm then create a specific template for that custom-subterm called taxonomy-custom-subterm.php.
Inside you could display all relevant informations/metadata to the custom-term.
If your custom-taxonomy is set to hierachical (which is the default behaviour I believe), then the url should be /custom-taxonomy/custom-term/custom-subterm/.
Graphical representation
domain.com/
L custom-taxonomy/
L custom-term/ (using taxonomy.php OR taxonomy-custom-term.php as template)
L custom-subterm/ (using taxonomy-custom-subterm.php as template)
This is based around the default Wordpress hierarchy.
Learn more # https://developer.wordpress.org/themes/basics/template-hierarchy/.
And # https://developer.wordpress.org/files/2014/10/Screenshot-2019-01-23-00.20.04.png

Wordpress getting template for post category type to work

Hiall,
In my wordpress site I have a Category called “meetings”, and it’s slug is “meeting”, also its ID is 27.
I create a default post article and then select “Meeting” from the categories panel and then publish etc.
Reading here
http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display
If I create a template file called category-meetings.php or category-27.php then it should pick those files up and use them for a template layout for my selected Meeting category posts etc???
But for whatever reason I can not get it to do this.
I have also tried changing the permalinks settings from “post name” to custom structre with /%category%/%postname%/
but again no luck.
Am I missing something here?
Any help would be great!
I think you're trying to target a single post, whereas your template is targeting the category archive pages. For example, look at this diagram of the template hierarchy.
You could:
1) Create that post as a page and then create a template just for that page.
2) Create a custom post type and create a custom template for that custom post type.
The naming has to match your slug. I would change
category-meetings.php
to
category-meeting.php
And make sure the category-customname.php files are in the same directory as the default category.php file.
Addition/Revision
For a custom page for a single post -- find the post number, let's say 999, then create a single page with the past number appended to the file name in the same directory where the single.php file exists. This worked up to WP ver 3.2-ish. Unless it's been deprecated, it should still work.
single-999.php

Wordpress, alternative single post template

For a project of mine I need to define an alternative template for single posts.
To be more specific I need each post to be displayed as usual when the website is browsed but I need to create different single pages reachable from different URL to create a sort of a mini-website for each post.
(I'm actually using the WooCommerce plugin and what I need to do is to create a mini-website for each product. This needs to be something "outside" from the main website, with a complete different graphic template and is going to be reachable through a QR-code).
Hope it makes a bit of sense.
Thanks for your advices and/or suggestions.
Angelo
I think the easiest way to do that is by registering a custom post type for the special posts that get this special "single.php" template. Then, you can simply write a new single template titled post-[custom post_type].php. Any post you register of this type will use that template.
OR...
If you don't actually need them to be posts, it's even easier if you publish them as pages. By default, pages let you assign a specific page template in the edit screen. So you could make any number of custom templates. Just make sure you add the special header:
/* Template Name: Custom Page */
...so WP knows it's a page template.

Display a Drupal page without the page template

Hello I am trying to generate a Drupal node which would be similar to a feed page generated by views module. I need to generate an xml feed, so I would not want to show the regular drupal template that is showed up on every node. I am trying to understand how the views for feed works as I want to display my page in a similar fashion, without the drupal template. Any suggestions would be great.
In Drupal you can theme any individual page to be completely different than the default template. So, if you have a node, let's say the url is "node/14", you can create a new template file called "page-node-14.tpl.php" in your theme folder. In this template you can add any html/xml markup you need. Also, for that specific node you should also create a "node-14.tpl.php" to theme that node's content.
If you want to display more nodes on a page, something like "taxonomy/term/3" (here you can find all nodes tagged with the term with the ID 3), you have to create a "page-taxonomy-term-3.tpl.php" template in your theme folder. To theme every node from one particular content type, you should create a "node-news.tpl.php" (this is for news node types) in your theme folder.
Please keep in mind that these template suggestions are for Drupal 6. In Drupal 7, the template name changed from "node-news.tpl.php" to "node--news.tpl.php"

Drupal 6: Drupal Themer gives same candidate name for different type of content types

I'm a drupal newbie...
I have different type of contents like News, Events, etc. and their content is different. News detail page has title-content text-date. but Events detail page has title-date-content text-location-speaker-etc. So I need different layout page for these different types. So, I enabled Drupal Themer to get a candidate name. for events page, it gave me page-node.tpl.php and it gives same for News page as well :( how can I separate these pages? I expected sth like page-event-node.tpl , but no... :/ Drupal Themer also give unique candidate name for event page like page-node-18.tpl.php but it doesnt mean anything since I can not create a general layout for all events by this node name. :(
Appreciate helps so much!! Thanks a lot!!!
While using different node.tpl.php files as suggested by monkeyninja (+1) would be the 'normal' way, you could add the functionality you want by adding page template suggestions based on node type yourself, in a preprocess_page function within a custom module/theme:
function yourModuleOrTheme_preprocess_page(&$variables) {
// If this is a node page, add a page template suggestion based on node type
if (isset($variables['node'])) {
// Build the suggestion name ('.tpl.php' suffix will be added by the theming system)
$suggestion = 'page-type-' . $variables['node']->type;
// Add to end of suggestion array, thus keeping the fallback to other suggestions,
// if this specific version is not implemented by the theme
$variables['template_files'][] = $suggestion;
}
}
With this in place, you should be able to add e.g. a 'page-type-event.tpl.php' file, which should be used for all event node pages.
(NOTE: You'll need to trigger a rebuild of the theme registry after adding that function to get it recognized by the system)
I'm not familiar with Drupal Themer, but a slightly different approach would be to work with the node templates to style the content and use something like the excellent Context module (and possibly Panels module) to change the layout of any additional information on the page (eg the blocks).
To theme the different content types using node templates, just create templates based on node.tpl.php in the form node-content_type.tpl.php. So you'd have a template for your events nodes called node-events.tpl.php.
You could then define a context using the Context module that reacted when a page of the events content type was displayed and select which regions/blocks you wanted displayed.

Resources