home resources search newsjoinmembers: 6958
PHP Flash Java Ruby Windows Linux
Hiveminds | Mon, 2006-01-02 08:06  tags:

As of version 4.6 the phptemplate engine has been move to the drupal core. this is probably the single most important improvement to Drupal since it's invention. I personally do not like templating engines like Smarty that use PHP to create another language that has to be learned. The users of PHP content management systems should learn PHP and beableto get what they want from the framwork. Learning Smarty or the tens of other templating languages is only confusing and in the long run not profitable.

printer-friendly version

Hiveminds's picture
This article brought to you by the Hiveminds Magazine - Staff. Contact us if you want to post an article or announcement anonymously
Thoughtbox - So what did you think?



Hiveminds posted on: Sun, 2005-09-11 14:51.

This error still lingers in v4.6.3 even though phptemplate has been moved to the core system. The erro occurs noticebly with php5.

Changing the following line which can be line 109 to 112 from

<?php

    $value 
variable_get('phptemplate_' $type '_links''');
?>

to

<?php

    $value 
variable_get('phptemplate_' $type '_links'false);
?>

Will

Hiveminds posted on: Thu, 2005-12-15 12:53.

When using Drupals tempalting system phptemplate it can be very restrictive if every module has to use the same page template. This causes some very complicated PHP code to be used to organize the different views of information. To solve this you can add in a list of template pages. This is untested psuedo code:

<?php

function _phptemplate_variables($hook$vars) {
  
$vars = array();
  if (
$hook == 'page') {
    if (
some condition) {
       
$vars['template_file'] = 'custom_page1';
    }
    else if (
some other condition) {
      
$vars['template_file'] = 'custom_page2';
    }
  }
  return 
$vars;
}
?>

Hiveminds posted on: Thu, 2005-12-15 13:31.

One of the nice things about Mambo is that the Control panel allows you to control where and how the main navigation links appear on the page. This is not as easy to do with Drupal but with the help of phptemplate it can be done with just a few lines of code. An example of this is when a login link is replaced by its logout counterpart after a user has logged in. Another nice usability feature is having an administration button appear if the user has those priveleges. You can accomplish these niceties by using the following in you page.tpl.php of Drupal phptemplate system.

<?php

if (is_array($primary_links)){
     
$contentStr .= '<div id="primary">'."n";
          foreach (
$primary_links as $link){
                
$contentStr .= '<div class="primary-a"><div style="background:#FFFFCC;padding-bottom:4px;">'.$link."</div></div>n";
          }
            global 
$user;
            if(
$user->uid){
            if(
user_access('access administration pages')) {
              
$contentStr .= '<div class="primary-a"><div style="background:#FFFFCC;padding-bottom:4px;">'.l('admin''admin')."</div></div>n";
            }
               
$contentStr .= '<div class="primary-a"><div style="background:#FFFFCC;padding-bottom:4px;">'.l('logout''logout')."</div></div>n";
            } else {
               
$contentStr .= '<div class="primary-a"><div style="background:#FFFFCC;padding-bottom:4px;">'.l('login''user/login')."</div></div>n";
            }
     
$contentStr .= '</div>'."n";
    }
    if (
is_array($secondary_links)){
          
$contentStr .= '<div id="secondary">'."n";
          foreach (
$secondary_links as $link){
                
$contentStr .= ''.$link."n";
          }
          
$contentStr .= '</div>'."n";
     }
?>

This example can be seen used here at Hivemindz Magazine when you log in and out.

Hiveminds posted on: Thu, 2005-12-15 14:34.

Frequently I want to get make some design or template based on the type of node or parts of the node that is loaded. A good example is wanting to change the sidebars or hide them on story nodes. While the node id is available the type of node is not readily available to the template page. Adding the following to the top of your page.tpl.php will let you make designs based on the type of node being loaded into the page.

<?php

if (arg(0) == 'node') {
  
$node node_load(array('nid' => arg(1)));
}
else {
  
$node NULL;
}
?>

Hivemindz Magazine - Editor

Mike Gifford - posted on: Sat, 2006-03-11 06:00.

In looking for that error I came here. Looking fro a drupal cvs change, but still.

Would be nice to know where the code snippet came from.

Mike

Hiveminds posted on: Sat, 2006-03-11 08:07.

This comment seems to have fallen away from the parent node. I can't find the original post that it should be attached to which is probably a result of me removing the forum. I'll have to look up everything again. But as I remember the array problems occured in the phptemplate.engine file.

Hivemindz Magazine - Editor

 
 
ASP.NET Content Management Systems Wordpress Silverlight PHP Content Management Systems
 videos
 articles
 blogs
 comments
 downloads
sitemap

Newsletter

Get updates on Hiveminds services, articles and downloads by signing up for the newsletter.

Editor's choice

Some of the better articles, stories and tutorials found at Hiveminds.

Find more

Find more of Hiveminds articles, stories, tutorials and user comments by searching.




Picked links

Hand picked websites and articles from around the web that provide quality reading.

page top