views:

141

answers:

2

I've had to move my page title into my node to accommodate a client need, but I'm unable to now get a title to display on a page view of my views list. The argument I have to display title on edit, admin and track pages is:

<?php if ($title && ((arg(2) == 'track') || (arg(2) == 'edit') || 
  (arg(0) == 'admin'))): ?>
    <h1 class="title"><?php echo $title; ?></h1>
<?php endif; ?>

and I'm wondering if there's a generic argument to include either all views list pages, or, the inverse, just exclude all node pages (NB: I'm using CCK, so have a lot of content types)?


Sniffing out other possibilities...

I know that I can create different page templates for my content-types, but can I create one different page template for ALL my CCK content-types?

Here's the code I'd through into template.php to get the ability to add individual content-type templates:

function _phptemplate_variables($hook, $vars) {
  switch ($hook) {
    case 'page':  
      if ($vars['node'] && arg(2) != 'edit') {
        $vars['template_files'][] = 'page-'. $vars['node']->type;
      }
      break;
  }
  return $vars;
}

Cheers
Steve

+2  A: 

OK - I found my own solution that didn't require creating 20 plus page templates. For the above example, I added the condition of !node->type to my query, since view's don't provide a node-type, then went through the site ensuring that title's were disabled at the page view level where needed.

<?php if ($title && ((arg(2) == 'track') || (arg(2) == 'edit') 
  || (arg(0) == 'admin') || !$node->type)): ?>
    <h1 class="title"><?php echo $title; ?></h1>
<?php endif; ?>

Thanks for listening :-)
Steve

Steve Perks
A: 

In case someone else is researching some similar questions, another way to provide an argument in the node.tpl file that would apply to when the node is displayed via a View (module) would be to use:

if ($page == 0)

Anything that follows would be ignored for a "regular" display of a single node. This doesn't work on a page.tpl so if one needed to put the title back in for all pages generated via Views, it could be added in a views-view.tpl.php file and added to the theme. Or other more specific Views tpl files could be added for certain types of Views.

Matt Winters

related questions