Drupal 7 theme template file names not working - php

I have extensively read many articles and the Drupal docs on how to create Drupal 7 theme templates, but for some reason none of the recommendations are working.
I have fresh install as of Friday, I have uninstalled all Modules. I have only created 3 basic page with a machine name of "page", a Content Type with the machine name of "staffers". I have my wrapper in page.tpl.php, which is working.
I can get the staffers content type to work only if I use node--nid.tpl.php ("node--6.tpl.php"), however I can not get node--staffers.tpl.php to work.
Additionally page--id.., or node-id.. will not work for the "page" content so I can't even figure how I can write a single custom template for each page id I want, or an overall template for the "staffers" content type.
I have nothing coded in my template.php at this point, and even with customethemename_preprocess_node being added I was unable to load the page--front.tpl.php I read about once.
So how do I get Drupal to load the template by nid or machine name for pages and custom content types?

In drupal-7, page--front.tpl.php should be appeared by default. You can check whether you have uninstalled any core module or not.

Related

schemaorg Module Drupal 7 is not working

I have installed schemaorg Module in Drupal 7 Project, and have followed instructions in this video.
But it is not working for me.
I have tested it on this link.
But it is showing me the following result:
0 ERRORS 0 WARNINGS 0 ITEMS
And in source code as well I am not able to find any code for micro data...
Enable core RDF module along with Schemaorg module. You won't see any changes. If you go to admin area for content type there will be some new options. The link for all available types you can use: http://schema.org/docs/full.html
Please read this great article: https://www.lullabot.com/articles/how-does-rdf-work-in-drupal-7
UPDATE
I did some research, apparently according to google, JSON-LD is the recommended format, not RDFa as I thought. I fired up a new project on https://simplytest.me and I installed schemaorg module first. I had errors when I paste code snippet from Person content type, check here, but when I removed sioc:Item foaf: from typeof="" the errors were gone. Check here. Apparently you need to find the way through your template file to remove those extra lines in order to work from google search engine.
I tried new solution, and installed module which worked rightway from installation, which supports google JSON-LD, and the results were perfect!! The name of the module is structured data but you also need to install all dependencies, I think meta tags module, token.
When you visit the page in admin/config after installing you will see at the bottom of the page STRUCTURED DATA (RICH SNIPPETS) - MAIN CONFIG where you can add site name and logo. When you create new content let's say article, on the left sidebar you will see Meta Tags, if you want to add some futures, or disable.
Just to add that it is very important the theme you are using. If you are using custom theme (like from your example) bear in mind that HTML code should be well structured.
There is also nice article adding structured data to Drupal 7 nodes, with some examples which can help you to dive into tpl files.
I hope it helps

How to add different template for different nodes in Drupal 6

I have 3 nodes in my sites.
node/1 - Login
node/2 - Contact
node/3 - Register
I want to have different template for different nodes. If I do as page-node-1.tpl.php , page-node-2-tpl.php , its for the entire page, I don't want that, I want specifically override for node content.
I have already tried the following links:-
Custom template for specific node in Drupal 6?
Using different templates for different nodes in Drupal 7
I am using Drupal 6
I have not used Drupal 6 in a while, but from what I realized, Drupal 6's default node templates will not have a node ID based template suggestion.
That does not mean you cannot do it from a custom theme.
<?php
function THEMENAME_preprocess_node(&$vars) {
$vars['template_files'][] = 'node-' . $vars['nid'];
}
?>
In your theme's template.php, add the above code, replacing the theme name (or merge the function contents if you already have that function). This will make the Drupal check for node-123.tpl.php file (123 being an example node ID), and will use it for in place of node.tpl.php.
Since you mentioned you'd be using node/1 or any node contents to embed a login form, let me tell you that this isn't exactly a good idea. The login form needs to be accessible when the site is in maintenance mode, and it can be hard to manage them later with different deployment environments. This part is completely irrelevant to the question though.

Creating custom joomla pages

I am building in Joomla! version 3.3.6 for my first time. I have built a ton of custom Wordpress in the past. The first challenge I have encoutnered, is the requirement of building a page which does not look anything like the template pages. The client desires a landing splash page, with large images and a gradient background. However, they are using a template already. Now, I know that I shouldn't start my research on Stack Overflow, so I've watched hours of tutorials for beginners on Lynda.com. No one seems to be covering this topic. Any help would be really appreciated.
To explain this idea, I will compare to what I would do in Wordpress. I would create a file named "page-splash.php" and give it a template name: Splash. Then I would fill this page with my choice code. Finally I would create a "Page" object in wp backend and give it the "template" of "splash".
This is very possible and often accomplished in Joomla.
You would simply need a second template installed and assigned to the page. In Joomla, you could technically have a different template installed for every single page if you wanted to. But in this case, you just need a 2nd template.
Start by building a bare bones template, as found here: https://docs.joomla.org/Creating_a_basic_Joomla!_template (or copy the current template from /templates/ directory and update the templateDetails.xml file so it will install as a second template)
Install 2nd template via Extension Manager
Next, make sure your new page is linked within the Menu Manager (as you will need a menu assignment to call the new template in next step)
Go to Template Manager and you can assign your new template to the menu item defined in the previous step.
You now have 2 independent templates running on the same installation and they can be styled and configured independent of one another.
Assigning more than one template is such a common task in Joomla that you can find more details about this in the official documentation: https://docs.joomla.org/J3.x:Switching_templates
Joomla is by Default not a Blog/Template layout cms, but rather a web application builder.
You can get extensions to create custom templates that make Joomla function like a blog application such as ZOO or K2. I would not go the route of creating individual templates for each page as it would be similar to installing a different theme for each page on a WordPress site.

OpenCart show own module on sidebar

I'm working in OpenCart 1.5.5 on some sort of newsmodule for in the side bar. I've got it all running in the back-end, but i don't know how i could asign this module module/aselsi to the right side bar on the home page, product page and category page.
I've already looked in some source code's, but i don't fully understand how this particilur thing works.
I did try to make it work by inserting in the DB tabels oc_layout and oc_layout_route some info, but that also didn't work.
So my question is: How can i make my extension / module apear on the front-page?
By running in the back-end I guess You have created a custom controller, model and view for some form where You manage Your news. That is OK.
But since this should be a module You also have to create a backend part for this module so that it could be installed and assigned to the layout on certain pages. The simplest way how to do this is to copy these files:
admin/controller/module/banner.php
admin/language/<YOUR_LANGUAGE>/module/banner.php
admin/view/template/module/banner.php
into Your new
admin/controller/module/aselsi.php
admin/language/<YOUR_LANGUAGE>/module/aselsi.php
admin/view/template/module/aselsi.php
and rename all the class names, constants, model and language file names from banner to aselsi. After this You should see a new Aselsi module under Extensions > Modules in You administration where You should be able to assign this module to pages and positions...
Just want to mention that simple copy-paste + rename is not enough, You would have to edit some other parts as well to get it working.
EDIT: I'm not at the code right now, but yes, You are right, it has a lot to do with that line You are mentioning in comment. Each module setting is saved as serialized string (which is a serialized array) which contains module settings - layout, position, sort_order, etc. The key is the module key - aselsi in Your case, same as all other modules has their own modules. By only installing the module You set the module as active but You can show the module by saving it's settings. In frontend controllers for left, right column and top and bottom content the active modules are then populated and all set to display on that layout and on that position are displayed then.
The installing/uninstalling of module (in backend) can be extended to e.g. add/remove new DB tables for that module and/or for altering current DB tables (by adding new columns, etc.) by implementing install and uninstall methods with their respective logic.
I hope this simple explanation helps a little.

problem with new content type created via module

I trying to write a drupal module. I'm following book "Learning Drupal 6 Module Development ". I have created a new content type (mybio)in module. I'm able create new node and edit node for new content type , it works fine but I'm not able to see new fields for mybio content type when viewing node.
I have placed mybio_info.tpl.php file in module folder and theme folder but nothing works.
Have you implemented the load hook and view hook?
Whenever you create new content types, you need to provide all hooks for changing / loading nodes, such as hook_delete(), hook_insert(), hook_load(), hook_update(), hook_validate() and hook_view().
If that doesn't work, are you sure your template is being used? If not sure, replace all its contents by something simple like '1' and see if that's being shown. If you don't see that, then it's not being used at all; try renaming to node-mybio.tpl.php.
For template naming, take a look at the Core templates and suggestions handbook page.
It looks like you did not implement hook_theme, so the system has no idea you are providing it with a template for this content type.
You can check whether this is the problem by displaying the theme registry using devel.module, or go further and use theme_developer module to check which template is used for everything on-screen.

Categories