I've created a node-flexinode_n.tpl.php file for customizing the output of a custom content type within my phptemplate theme. It's working great in how it formats the flexinode content, but my flexinodes are now missing important links that are usually generated through printing $content: book navigation links and relativity links.

I need to instruct my flexinode template file to include the usual node output (found at the bottom of the node. I've tried including

, but this only displays the "add child page" and "printer friendly" links, even though I'm looking at a top level book page with child pages already attached. There should also be some relativity "action" and "view" links showing up from the node relativity module. If I print $content for this node-type, the expected links appear.

How do I get them to show up in my custom output through my flexinode template? Any suggestions or solutions would be greatly appreciated! Thank you in advance!

Comments

bomarmonk’s picture

I'm still pretty sure I must be overlooking something rather simple: but I have looked through the node.tpl and page.tpl files without discovering how I need to print the book navigation links with my custom flexinode .tpl files. Anyone run into this issue and find a solution. Suggestions would be much appreciated!

Dublin Drupaller’s picture

Hi bomarmonk..

I too am playing around with themeing flexinode although it's slow progress as I'm not a programmer.

Just an idea..but, according to the node.tpl.php handbook page the $links variable should be available...but if it's not working for you, you may have to make make additional variables available to your flexinode-x.tpl.php file...i.e. edit the template.php file...

Hope that makes sense..I'm guessing and am unsure how to code something like that, but, it may spark an idea on your side.

Please post back up here if you get it sussed...am trying to dig out as much knowledge about theming flexinodes to put together a few handbook pages.

cheers and I hope my idea isn't a cul de sac, just thought I'd mention it as nobody else voluntered anything.

Dub

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

Dublin Drupaller’s picture

Hi again,

have you tried this?

 if ($node->links) {
    $body .= "<hr /><div style=\"text-align: right;\">[ " . theme("links", $node->links) . " ]</div>";
  }

found that here: http://drupal.org/node/19532

Dub

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

bomarmonk’s picture

With the following code, I only get the "printer friendly version" link and the "add child page" link, but not the book nav links or the relativity module links:

if ($node->links) {
$body .= "


[ " . theme("links", $node->links) . " ]

";
}

It's better than nothing, but I'll keep exploring the reason why the others aren't displaying. It could be a general theming issue that is unintended. Right now, I've hacked together a hybrid of spread-firefox and lincoln's revenge for my theme. It could be that there are some .css settings that are interferring? I've gone over my

and and
structure in my node-flexinode-x.tpl.php file., but don't see any tags that haven't been closed, etc.
laura s’s picture

Re the book navigation output problems you mentioned: In your style.css file for your theme, search for .book (the entire book navigation area), .tree (the subordinate pages list), and .nav (the previous, up, next links) and see if any are shown as display: none;.

As for the $links, CSS would not affect which links would show from the $links output, just how the output will look.

===
Laura
pingV

_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet

bomarmonk’s picture

I wasn't uploading my node-flexinode-x.tpl.php file to the right place with your suggested code. Now that I discovered my upload oversights, your suggested code doesn't seem to work. If I simply include it at the end of the tpl.php file, the code is printed to the browser.

I tried changing the code to:
<$php if ($node->links) { $body .= "


[ " . theme("links", $node->links) . " ]

";}:?>

But this also prints the code to the browser. What did I do wrong in trying to implement this little piece of code? Thanks for more help!

Dublin Drupaller’s picture

HI Bomarmonk...

Is there a way to define your flexinode content as a "book" page?

i.e. so when drupal is generating the links for the flexinode, it treats the flexinode as a book. So when you call the print node->$links instruction, it will generate links associated with books rather than a non-book node..if you know what I mean.

if that isn't a runner or it's simpler to just generate the links from within your flexinode-x.tpl.php file..I have dug out the function in the book.module that generates the book node links..

Have pasted it below in case it sparks any ideas for you...

Dub

/**
 * Prepares both the custom breadcrumb trail and the forward/backward
 * navigation for a node presented as a book page.
 */
function book_navigation($node) {
  $path = book_location($node);

  // Construct the breadcrumb:

  $node->breadcrumb = array(); // Overwrite the trail with a book trail.
  foreach ($path as $level) {
    $node->breadcrumb[] = array('path' => 'node/'. $level->nid, 'title' =>  $level->title);
  }
  $node->breadcrumb[] = array('path' => 'node/'. $node->nid);

  if ($node->nid) {
    $output .= '<div class="book">';

    if ($tree = book_tree($node->nid)) {
      $output .= '<div class="tree">'. $tree .'</div>';
    }

    if ($prev = book_prev($node)) {
      $links .= '<div class="prev">';
      $links .= l(t('previous'), 'node/'. $prev->nid, array('title' => t('View the previous page.')));
      $links .= '</div>';
      $titles .= '<div class="prev">'. $prev->title .'</div>';
    }
    else {
      $links .= '<div class="prev">&nbsp;</div>'; // Make an empty div to fill the space.
    }
    if ($next = book_next($node)) {
      $links .= '<div class="next">';
      $links .= l(t('next'), 'node/'. $next->nid, array('title' => t('View the next page.')));
      $links .= '</div>';
      $titles .= '<div class="next">'. $next->title .'</div>';
    }
    else {
      $links .= '<div class="next">&nbsp;</div>'; // Make an empty div to fill the space.
    }
    if ($node->parent) {
      $links .= '<div class="up">';
      $links .= l(t('up'), 'node/'. $node->parent, array('title' => t('View this page\'s parent section.')));
      $links .= '</div>';
    }

    $output .= '<div class="nav">';
    $output .= ' <div class="links">'. $links .'</div>';
    $output .= ' <div class="titles">'. $titles .'</div>';
    $output .= '</div>';
    $output .= '</div>';
  }

  $node->body = $node->body.$output;

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

bomarmonk’s picture

And the odd thing: some book links are showing up. "Printer-friendly version" and "add child-page," both links from the book module, do appear correctly using print $links. The node relativity and book navigation links (this is a parent page, so the child pages should appear and the "next" navigation link should also appear) are not displaying where they are expected.

I'll try tweaking with how I'm wrapping the custom output of my .tpl.php file... maybe the book module will provide the proper clues for me to solve this.

bomarmonk’s picture

I'll dig around for possibilities using other variables... as the $links variable only seems to ouput "printer friendly" and "add child" links, but not the "next/previous" book links, or the "related" node links produced through node relativity... there must be a way to output those links, since print $content gets at them. I'll let you know if I discover anything useful.

laura s’s picture

This is just a guess, but have you checked your access controls? If you don't specifically enable access to those flexinode types, display will be affected. I suggest this only because the $links output is dependent upon permissions of the user.

===
Laura
pingV

_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet

bomarmonk’s picture

It looks like I have a "edit own flexinode_x" and "create flexinode_x" permissions, but I believe the book nav links are unaffected by these two settings. Also, if I simply print $content for the given flexinode type, the links show up as expected with the appropriate users being able to use and see the links. Unless something weird is going on with access controls that I cannot adjust in the access table, I don't think the links are being hidden by any access controls. Do I need to put some sort of hook in my node-flexinode_x.tpl.php file? So that it correctly interacts with the book module and other modules? I don't know...

laura s’s picture

On our own site, we have custom flexinode types pulled into book hierarchies all over. The only way I've manipulated the display of the book navigation was by adding/removing 'display:none;' to the appropriate CSS definitions in style.css.
===
Laura
pingV

_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet

bomarmonk’s picture

The following styling is found in my layout.css file:

.book, .book .nav, .book .nav .links, .book .nav .titles {
clear: both;
}

And...
.book .title {
font-weight: bold;
font-size: 1em;
margin-bottom:1em;
}

I tried removing the "clear: both," but this did nothing. I've also tried using another theme with same node-flexinode-x.tpl.php file and I have the same problem. So, something else must be going on between my tpl.php file and the way the node usually gets outputted with links. As I mentioned before, any of these themes print out the book nav links correctly as long as the tpl.php file isn't involved. I am still mystified. Thanks for your help so far. Hopefully someone still has something for me to try? Maybe, Laura, you might be so kind to send me a copy of one of your tpl.php files that works with book navigation? Maybe the example would shed some light on what I'm missing... or what my file is missing? Thanks for any further suggestions.

laura s’s picture

"clear: both;" will only force placing that element on a new line (it clears the element of any "float"-instructed elements) -- it would not affect visibility.

Here is the content of one flexinode template file we've used on a site with no problems:

<div class="node<?php print ($sticky) ? " sticky" : ""; ?>">
<div class="node-<?php echo $node->type ?>">
			<div class="terms"><?php print $terms ?></div>
<div id="node-services-box">
    <h2><a href="/<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
  <div class="content">
  <?php print $content ?>
  </div><br />
    	<div class="links"><?php print $links ?></div>
		  <?php if ($page != 0): ?>
         <div id="serviceinfo">Updated <?php print $date ?></div>
  			<?php endif; ?>
</div>
</div>
</div>

As you can see, it's pretty basic. Hope this helps.
===
Laura
pingV

_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet

bomarmonk’s picture

I appreciate your feedback on this issue and I've tried wrapping my flexinode theming in the <div class="node"> because I had not included this in my theme. Unfortunately, this did not correctly include the missing links.

There is a key difference between your example and the flexinode theming I am trying to accomplish. You are using the theme to alter the larger attributes of the node output. For your content/flexinode fields, you are generating them with the command, "print $content." My flexinode does include the proper links if I use "print $content."

I am theming each flexinode field so that I can make it display in a table (the table layout works great). Here's my node-flexinode-5.tpl.php (maybe including the entire content of what I have so far will point out some obvious omission on my part) This produces the layout and theming that I want, but again, it isn't outputing the book links and other node links correctly (only the "print-friendly" and "Add-child" links show up):

<div class="node<?php print ($sticky) ? " sticky" : ""; ?>">
<div class="node-<?php echo $node->type ?>">
<div class="content">
<div id="about_node">
<div id="org_header"><h1>Contact Information</h1></div>
<div id="address_pad">
<table id="flexifield_five">
<tr id="info_row"><td id="address_column">

<table id="address_table">
	<tr id="address_label" class="label_row"><td id="address_label" colspan="3">ADDRESS:</td></tr>
		<tr><td colspan="3" class="hr_org"><hr /></td></tr>
	<tr id="address_row_one"><td id="address_line1" colspan="3">
	<?php print $node->flexinode_11 ?>
	</td></tr>

	<tr id="address_row_two"><td id="address_line2" colspan="3">
	<?php print $node->flexinode_12 ?>
	</td></tr>
	<tr id="address_row_three">
	<td id="three_column" colspan="2">
		<table id="three_table">
		<tr id="three_row">
		<td id="address_city">
		<?php print $node->flexinode_13 ?>,
		</td>
		<td id="address_state">
		<?php print $node->flexinode_14 ?>
		</td>
		<td id="address_zip">
		<?php print $node->flexinode_15 ?>
		</td>
		</tr>
		</table>
	</td>
	<td id="row_three_space">&nbsp;</td>
	</tr>

    <tr id="address_row_four">
    <td id="address_cell_four" colspan="3">
    	<table id="phone_fax_table">
    	<tr id="phone_label_row">
    	<td id="phone_label">PHONE:</td>  <?php if ($node->flexinode_17 != ""): ?>
    	<td id="fax_label">FAX:</td>
   		<?php endif; ?>
    	</tr>
    	<tr><td colspan="3" class="hr_org"><hr /></td></tr>
    	<tr id="phone_content_row">
    	<td id="phone_number"><?php print $node->flexinode_16 ?>
    	<?php if ($node->flexinode_52 != ""): ?>
    	 &nbsp;ext.<?php print $node->flexinode_52 ?>
    	<?php endif; ?>
    	</td>
    	<td id="fax_number"><?php print $node->flexinode_17 ?></td></tr>
    	</table>
    </td>
	<?php if ($node->flexinode_22 != ""): ?>
	<tr id="email_label" class="label_row"><td id="email_label" colspan="3">E-MAIL</td></tr>
	<tr><td colspan="3" class="hr_org"><hr /></td></tr>
	<?php endif; ?>



	<tr id="address_row_five">
	<td id="address_email" colspan="3">
	<a href="mailto:<?php print $node->flexinode_22 ?>"><?php print $node->flexinode_22 ?></a>
	</td></tr>
	</table>

<td id="org_image"><img src="/<?php print $node->flexinode_8->filepath ?>" class="org_pic"></td>
</tr>
</table>
</div>
</div>
<div id="org_desc">
<div id="about_org" class="org_about"><h1>Additional Details</h1></div>
<div id="org_body"><?php print $node->flexinode_51 ?></div>
</div>

<?php if ($links): ?>
  <?php if ($picture): ?>
  <br class="clear" />
  <?php endif; ?>
  <div class="links"><?php print $links ?></div>
  <?php endif; ?>
</div>
</div>
</div>
laura s’s picture

The div class tags won't do anything but provide the ability to format your content in CSS. It would not affect the php functionality at all.

Setting your custom code aside for the moment, if not even print $content isn't generating the book navigation on book pages -- or nodes that have been pulled into book hierarchies -- and CSS is not preventing display, that would seem to point to a problem with your module. I'm at a loss at this point, except to make the obvious suggestion of re-uploading the book module and flexinode module (and perhaps all core modules) and checking in a good text editor that you don't have any extra spaces or lines after '?>' in those files, and that everything's UTF-8. A database structure check might be in order, too (though I would think those errors would show up in your log).

If a default template displays the full links, though, then it could be your phptemplate engine that has a glitch. I've not had any problems with book navigation on a flexinode item, so this sounds not like a theme problem but rather a bug or corrupted file. Sorry I'm not any help here.

===
Laura
pingV

_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet

bomarmonk’s picture

But I don't think I can use it and theme individual fields at the same time. If you look at my example, you'll see I have supplanted the print $content with a very specific table layout. If I use $print content, how would I include that command and the custom theming for each field? Right now, if I just throw print $content into my file I get the content produced twice in the same node: once with my custom formatting and once without the custom formatting but with the links (not good, obviously).

This is my dilemna. Maybe it is a simple solution.... Have you actually been able to break down each flexinode field and custom theme it (like I am doing in the above example) and have the book links display properly? I'm just curious if anyone has even accomplished what I'm trying to do. It seems like your example using print $content is a whole different creature... or is there a way to wrap my custom content into a print $content command... is this what I'm missing? Thanks for the help!

Again, the $print content call does produce the flexinode content with all the appropriate links. But I have only figured out how to produce a custom table output by using the above example and not using print $content.

laura s’s picture

Perhaps this is not ideal, and I've not tried it, but each flexinode field has a class tag -- that means each could be positioned using the position instruction in CSS. This has compatibility with most browsers (though not all variables will work with all browsers). Again, I've not tried it, but theoretically it's possible.
===
Laura
pingV

_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet

bomarmonk’s picture

...but I didn't know of a way to output the data in a table. Flexinode fields are displayed in <div> tags, so there is a great degree of limitation (particularly since I am a more capable layout guy when using tables). I tried to get the <div> floats to correctly position the fields, but this was a nightmare in terms of making the data display consistently over various screen resolutions and with various browser text sizes.

Thanks again for thinking of another suggestion, but I'm still hoping I can use that tpl.php layout for my flexinode. My problem almost seems like a supernatural occurrence at this point, but I'm sure someone with a little more knowledge could peel back my shroud of superstition. There's got to be an explanation and a solution-- a way of getting those node links to display correctly with custom themed flexinode stuff-- right??

I hope so!

bomarmonk’s picture

At the end of my node-flexinode.tpl.php file, I tried adding

<div class="nav">
  <div class="titles"><?php print $titles ?></div>
  <div class="links"><?php print $links ?></div>
  </div>

But nothing changes! It seems like there should be something like this I can add into my template file to make:

  • The titles of children pages to appear in the parent page's index/table of contents
  • The proper "next"/"previous" navigation links show up.
  • And other node/module related links

    Help! This is one of the few finishing details that is preventing me from completing my site. Any other suggestions would be appreciated and I thank those who have already offered their ideas and suggestions!

laura s’s picture

Since you seemed to be pulling up variables on your own already, I did not mention this ... but it would seem to be that to call up anything not in the default variables for nodes you would need to add some variable functions to your template.php file.

Sorry I don't have any specifics off-hand.

===
Laura
pingV

_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet

bomarmonk’s picture

This is the output of my flexinode page links as they should be (if I'm not passing my flexinode through the custom tpl.php file). Note: by using print $links in my custom php template, I get only the "add child page" and "printer-friendly" links sent to the browser. I've tried printing $tree, $menu, $nav, and any other variable that might summon this other content into my custom theme. There's just got to be a few variables I can pass along to get the book tree, navigation links, and the node relativity links, right? This is all stuff that gets $outputted automatically as long as a custom tpl.php file is not involved:

<div class="book">
	<div class="tree">
		<div class="menu">
		<ul>
		<li class="collapsed"><a href="/departments/board_of_supervisors">Board of Supervisors</a></li>
		</ul></div>
	</div>
	<div class="nav"> 
		<div class="links">
			<div class="prev">&nbsp;</div>
			<div class="next"><a href="/departments/board_of_supervisors" title="View the next page.">next</a></div>
		</div> 
		<div class="titles">
			<div class="next">Board of Supervisors</div>
		</div>
	</div>
</div>
<fieldset><legend>Related Actions</legend><a href="/node/add/flexinode-9/parent/321">create new County Official</a><br/>

<a href="/relativity/listnodes/flexinode-9/parent/321">attach existing County Official</a><br/>
</fieldset>
</div>
      <div class="links">
      <a href="/node/add/book/parent/321">add child page</a> | <a href="/book/print/321" title="Show a printer-friendly version of this book page and its sub-pages.">printer-friendly version</a></div>
  </div>

<!-- end content --></div>
bomarmonk’s picture

Thanks to Steve Ringwood (a.k.a.) nevets for his help! Here is the solution he provided for adding all of the appropriate node links (I think I've included everything that needs to be at the end of the tpl.php file to get book navigation and relativity module links up and running):

<br />
<?php
	$node->body = "";
	$node->teaser = "";

	  node_invoke_nodeapi($node, 'view', FALSE, FALSE);

	print $node->body;
?>
<?php if ($links): ?>

    <div class="links">&raquo; <?php print $links ?></div>
    <?php endif; ?>
dtabach’s picture

I receive the following error message when I include this code at the end of my node-flexinode-x.tpl.php:

Parse error: parse error, unexpected ':' in /home/dtabach/public_html/themes/durval_blmrn/node-flexinode-2.tpl.php on line 31

Line 31 is the if ($links):  part.
I'm not a programmer, but I tried to replace the syntax using ':' by the one below, based on other pieces of codes that I've seen around:

<?php if ($links) { ?>
     <div class="links">&raquo; <?php print $links?></div>
     <?php } ?>

But I get the same message, just with a '{' instead of ':'.

I'm looking for the very same you are (display book navigation in a node-flexinode-x.tpl.php). As you told that code worked for you, I'd be really glad if I could make mine work also. Any tip??

Durval Tabach

bomarmonk’s picture

It works for me... I'm using Drupal 4.6.3. I'm wondering if maybe the error you are receiving has to do with the version of flexinode? I may be grasping at straws here, but I'm not a programmer, so I can only guess. I certainly don't understand what Ber is saying about the solution being incorrect. I still haven't seen the code for a better alternative, other than the Fleximax module or patch as discussed here: http://drupal.org/node/30376

As of yet, I haven't had a chance to use this new patch, but I'm curious if it cuts through the complexity of some of this. In the meantime, the aforementioned solution is still working for my site.

dtabach’s picture

I found the fix by chance.

As I already had the 'print &links' command in my node-flexinode-x.tpl.php file before adding the new code, I ended up with two 'print &links' after I added it.
When I removed the first one, it worked!

Durval Tabach

texas-bronius’s picture

bomarmonk-
your unofficial understudy (picturing sidekick kid in pixar's "The Incredibles") is hot on your trail running into same issues and similar solutions:

<br class="clear"/><?php $bjmnext = book_next($node);?><a href="/node/<?php print $bjmnext->nid; ?>"><?php print $bjmnext->title; ?> &raquo;</a>

This incomplete (lacking previous and up) snippet shows another possible solution based at a lower level against book.module. I think there's a more elegant way to produce hrefs (I hardcoded with paths whereas Drupal would otherwise decide whether to make ?q or path queries). Plus, different from books links, here you're able to put whatever you like as link text: here it's the title of the next page, alternately you might stick with "next" or "see more>>" or something else. I also included only "next" but previous ("prev") is just the same, and in our cases, Department is the top-level and will never have a Previous...

Merry Drupal'ing! Thanks for paving the way for the rest of us in your various posts :)

* note: some extra spaces were introduced upon posting to the forum

--
http://drupaltees.com
80s themed Drupal T-Shirts

Bèr Kessels’s picture

They are not the same.

book navigation is something that is added to the body of the node $node->body

In order to get that, you either need to pre-match against the body to grab the HTML from it. Hard to do, ugly code,
Or you need to invode the book navigation function. Lot of code, Lot of overhead and ugly too, be it less ugly that patternmatching.

Ber
---
if you dont like the choices being made for you, you should start making your own.
---
[Bèr Kessels | Drupal services www.webschuur.com]

bomarmonk’s picture

The last snippet of code works for me. Any possible problems that could be associated with this solution. The book links and others (relativity) now display properly... but I'm open to better solutions if I can actually see the example (I'm not good at coming up with this stuff on my own).