0

I have created a custom content type for each of several contributing users for multi-blog purposes. I then used Views to create a page for each content type and thus a "blog home page" for each user. I have also modified my theme's node.tpl.php file to reflect the custom look I want for displaying the teasers for all the custom content that is created.

The current header portion of my node.tpl.php file:

<?php if (!$page): ?>
  <header>
<?php endif; ?>
<span class="uppercase">
  <span class="blog_title"></span>
  <span class="post_date"><? print " | "; ?></span><? print render($date); ?></span>
</span>
<?php print render($title_prefix); ?>
<?php if (!$page): ?>
  <h2 class="title" <?php print $title_attributes; ?>>
    <a href="<?php print $node_url; ?>"><?php print $title; ?></a>
  </h2>
<?php endif; ?>
<?php print render($title_suffix); ?>
<?php if ($display_submitted): ?>
  <span class="submitted">By
    <span class="uppercase"><?php print $submitted; ?></span>
  </span>
<?php endif; ?>
<?php if (!$page): ?>
  </header>
<?php endif; ?>

I can display the custom content title with $title, the date it was submitted by $date and the author by $submitted. What I would like to include is the title/link to the page (that was created by the view of the custom content type associated with the author).

Is this something I can use relationships for to somehow generate a token and/or variable?

I don't really have any idea about how to approach this; any ideas or advice are much appreciate... thanks!

1 Answer 1

0
  1. In your theme template.php file add preprocess_node as below.
  2. The below code will grab the author of current node for your custom content type.
  3. And $node_author will be available to user on node.tpl.php
  4. With the help of $node_author you can make the link

    //
    //Override or insert variables into the node template.
    //
    function MYTHEME_preprocess_node(&$variables) {
      //dpm($variables);
      if($variables['type'] == 'my_custom_content_type') {
        $node_author = $variables['uid'];
        $variables['home_page'] = $node_author;
      }
    }
    
  5. In your views add contextual filter for author uid to grab from url.

  6. This should work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.