Drupal 7 block.tpl.php does not exist - drupal

I am new in Drupal and try to create my own Drupal theme. I have copied the Garland theme from theme/garland and pasted it to sites/all/themes/(renamed mytheme). But when I search on how to integrate templates in Drupal, there I got that I need four mandatory files: comment.tpl.php, page.tpl.php, node.tpl.php and block.tpl.php but in that theme there is no file name called block.tpl.php, inspite I have a template.php.
Please guide me on this, do I need to create block.tpl.php by myself?? If I create it what would be its content and how do I use that, also what is the use of template.php in my site.
I am new in this CMS (Drupal) so any response would be appreciable and helpful for me.

You can create your own block.tpl.php by copying it form modules/block to your theme's folder (remember to clear the cache!). template.php should contain custom overrides to the theme functions, as well as implementations of process/preprocess hooks. You can find an in-depth discussion about how Drupal's theme system work by following this link and in general by searching drupal.org website.

Related

Creating a wordpress theme

Just want to know that if I'm going to create a new wordpress theme, what about functions.php, should I need to create a new functions file, or just copy it from other wordpress theme. I have read codex but it only tells about the templates needed to create a new theme.
The theme functions file is a template used by Word-press themes. It acts like a plug-in and gets automatically loaded in both admin and front-end pages of a Word-press site.
The functions.php file can be found in your theme’s folder.
You don't need to create a new functions.php file when you want to put your own function in function.php just paste that code in your themes functions.php file.
You can look into these Reference Links to understand more about function.php file :-
Functions_File_Explained
You don't need a new functions.php file if you don't want custom functions in your theme.
See this thread for more information - not including functions.php doesn't make any difference for your custom theme.

Buddypress template hierarchy is not being used

I am updating an installation of buddypress (1.5) to the most recent version (2.1.1). I have updated the files and am now trying to update the theme to use the template hierarchy pattern.
For this I created the following directory structure within my theme:
my-theme/
buddypress/
groups/
index-directory.php
index-directory.php contains a single die('debug') statement for testing.
If I copy this buddypress directory into the twentyfourteen directory and activate that theme, I am seeing the debug message when I'm on the group listing page. However, when I use my custom theme, the message is not showing up.
This tells me that the template hierarchy is not being applied on my theme. Why could that be?
I suspect that somehow my theme is being treated as a legacy theme, I don't understand why though. I commented out the whole functions.php to make sure it's not because of aynthing in there. The header comment in the style.css does not contain anything special either.
Any help on this?
Thanks.
The problem was my own mistake. Our theme stylesheet had a Template: bp-default in it. I didn’t notice it at first because our theme is named similarly and my mind read it as the title of our theme. If I remove it, my templates are included.
For anyone stumbling on this problem in the future, here are the reasons why the template hierarchy could be deactivated by Buddypress:
Theme compat is disabled when a theme meets one of the following criteria:
1) It declares BP support with add_theme_support( 'buddypress' )
2) It is bp-default, or a child theme of bp-default
3) A legacy template is found at members/members-loop.php. This is a
fallback check for themes that were derived from bp-default, and have
not been updated for BP 1.7+; we make the assumption that any theme in
this category will have the members-loop.php template, and so use its
presence as an indicator that theme compatibility is not required
https://buddypress.org/support/topic/default-theme-is-still-showing/

Drupal 6 theme add / edit content form

Drupal 6 theme add / edit content form
In Drupal 6, we can add new content type "content-type".
We want to theme /node/add/content-type by template file.
We want to theme the edit form /node/$nid/edit of this content-type also by template file.
How to do this?
For this you need to understand the naming convention of tpl files in Drupal. This link will help https://www.drupal.org/node/1089642
According to documentation,
"http://www.example.com/node/1/edit" would result in the following suggestions:
page-node-edit.tpl.php
page-node-1.tpl.php
page-node.tpl.php
page.tpl.php
Either you can try adding content-type in the naming as suggested(I have not tried it personally), or if there are few customization to be done, adding a check like
<?php if($node->type == 'content_type_name') ?>
over available variables in "page-node-edit.tpl.php" will also do.

Hooking basic pages in drupal 7

I have few basic pages in drupal 7, named about, contacts. I tried to make page--about, and style it, but it doesnt work. Any advice on how to force hook basic pages?
In your themes template file you can get template suggestions. This was you can check there isnt anything weird going on. The following will dump out suggestions for templates.
You need to use the following:
function YOURTHEME_process_page(&$vars) {
var_dump($vars['theme_hook_suggestions']);
dsm($vars['theme_hook_suggestions']); //if you have Devel
}
You should install the Devel module, this helps alot with theming.
First make sure you're using the correct machine name for your content type. Go to content types and copy it from there.
Copy the node.tpl.php file from root/modules/nodes/ to your theme's templates directory.
Rename the node.tpl.php file to node--MACHINE_NAME.tpl.php.
Clear the cache in admin/performance/. This is important.

Can I use a wordpress theme in new php pages?

I'm putting together a web site that needed to include some signup and blogging capability. Wordpress seems to be a perfect fit for that portion of the app, so I've started experimenting with it. I see plenty of tutorials on creating custom themes so I don't expect that to be a problem.
What I'm not able to figure out is what to do with the rest of my site. I will have other non-blogging related php pages that will access a database, etc. I see that wordpress has a capability for generic pages of static content, but these would need to be coded PHP pages. I just can't find a way of having the wordpress theme apply to other php pages outside of wordpress. I was hoping of just doing something like
wp_header();
blah blah
wp_sidebar();
blah blah
wp_footer();
but I'm not really seeing any examples or documentation on how this might be done. Am I missing a key piece of documentation?
EDIT: The answer is to essentially copy and paste a file from the theme, with one crucial addition:
require( dirname(__FILE__) . 'path_to_wp_root/wp-load.php');
That sets up the wordpress environment and allows me to call get_header(), get_sidebar(), get_footer(), etc.
Generally, "yes".
A well-designed WordPress theme uses mostly CSS/Stylesheets for display, and you are correct in your assumptions: Look through the "Codex" about Theme Design / Template Design (http://codex.wordpress.org/Stepping_Into_Templates).
Essentially you could base your design on some of the current theme files, but leave out "the loop".
I think what you really want to do is include wp-load.php at the top of your php file. This will give you access to all the wordpress functions (wp-header(), wp-footer(), etc).
wordpress has pages in it. each page can have its own content and its own template and still be part of the whole wordpress site. i mean it will share the header and the footer if you want and will share the css and javascript that you include in both.
for more information on pages and pages templates
What you should do is develop your other non-blogging related php pages as a wordpress plugin. There are plenty of references online on how to do this, for example:
http://www.tutorialized.com/view/tutorial/Creating-a-Custom-Wordpress-Plugin-from-Scratch/41834
Another option is to use Wordpress as the CMS for all content on your site. This is increasingly becoming popular, as Wordpress is quite good at non-blog-things these days.
define('STYLESHEETPATH', '');
define('TEMPLATEPATH', '');
$base = substr(__DIR__, 0,strrpos(__DIR__, '/[name of the dir where u store the php files]'));
require_once($base."/wp-load.php");
require_once($base."/wp-includes/pluggable.php");
easy to use wordpress function outside

Resources