0

I created a custom panel layout with Panels 3 (following this excellent link) and my layout is ready. Now I have my static markup ready for a node (I can use it on the article or a custom content type) and I want to find out how to create a custom panel pane programmatically. I don't won't to do it through the UI as I want to totally control the dynamic markup of a node. to make things specific (but keeping a certain level of generality), imagine

<div class="post">
  <h3 class="title"> 
    <span class="date"> 
      <span class="day"> !!php dynamic day of the date!! </span> 
      <span class="month"> !!php dynamic month of the date!! </span>
    </span>
    <a href="#"> !!php dynamic title of the node!!  </a>
  </h3>   
  <div class="content"> 
    <p> !!php dynamic content(body) of the node!! </p>
    <div class="read-more" >
      <a href="#"> !!php dynamic read more text!! </a>
    </div>
  </div> <!-- end: content -->
</div> <!-- end: post1 -->

How can I achieve to manage the above dynamic node (and let's suppose I want to achieve an exact, specific markup)?

  • Would it be an option to export the panel to code, using features module, and then edit the code as you wish? Why can't you do dynamic stuff with custom views(written in code) that will be integrated into the panel? – Potney Switters May 26 '13 at 17:07
  • I don't want extra code in my site. I want it to produce the markup I want and not 20 divs more :) Moreover I have already done the (not so simple) styling for the markup and I don't want it(the markup) to change :) – Vagelis Kostopoulos May 26 '13 at 19:58
1

Ok my question maybe was not the best but at least I hope the following will help new themers get on track.

  • I created a custom content type called: seminar
  • I created this node--seminar.tpl.php and placed it inside /sites/all/themes/awesome (the name of my theme)
  • Inside this file I copy pasted the code found in /modules/system/node/node.tpl.php and I tweaked the code as follows.

    <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> post clearfix"<?php print $attributes; ?>>            
    <?php print render($title_prefix); ?>
      <?php if (!$page): ?>
        <h3 class="title"> 
          <span class="date">
            <span class="day"> <?php print $date_day; ?> </span>
            <span class="month"> <?php print $date_month;?> </span>         
          </span>
          <a href="<?php print $node_url; ?>"><?php print $title; ?> </a>
        </h3>
      <?php endif; ?>       
      <?php print render($title_suffix); ?> 
      <div class="content"<?php print $content_attributes; ?>>
        <?php 
          hide($content['comments']);
          hide($content['links']);
          print render($content); 
        ?>          
        <div class="read-more">
          <?php print render($content['links']); ?>
        </div>  
      </div> <!-- end: content -->
    </div> <!-- end: post1 --> 
    

Keep in mind that in order to achieve this

<span class="day"> <?php print $date_day; ?> </span>
<span class="month"> <?php print $date_month;?> </span>

so that $date_day and $date_month correspond to sth meaningful, I had to go through this. Othewise by default drupal outputs sth like <span> Apr 30 </span> and we can't target Apr and 30 seperately for CSS styling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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