<h2 id="gb4m">Theming Panels and Views<br id="b6xh"></h2>
<h2 id="gb4m"><font id="ru33" size="2">We chose to use the 'flexible' layout for all of the panels on MyPlay. Flexible allows the admin to set exact width units (%, em or px) in the layout settings for the total page as well as individual columns. Pixel-based column widths were essential for the new design, specifically for browser compatibility as safari tends to read % and em differently than other browsers. This is another big advantage of Panels 2 as Panels 1 is all percentage-based.</font></h2>Virtually every view we use has a custom theme function that allows us to recycle the view but change look and feel based on where/how the view is being called. We also account for this in the node tpl files as needed. Examples follow:<br id="qp48"><br id="zufk"><a title="http://myplay.com/artists/britney-spears" href="http://myplay.com/artists/britney-spears" id="yc5z">http://myplay.com/artists/britney-spears</a> <br id="d_rj">and<br id="z22r"><a title="http://myplay.com/music/britney-spears" href="http://myplay.com/music/britney-spears" id="g195">http://myplay.com/music/britney-spears</a> <br id="c19e"><br id="w-.p">use the same standard linked image/linked title list view for the music block:<br id="v16."><div id="k_8j" style="padding: 1em 0pt; text-align: left;"><div id="hvnj" style="padding: 1em 0pt; text-align: left;"><img id="lx9y" style="width: 671px; height: 320px;" src="File?id=ddc4hxf4_5gqxfr9gt"></div>In our theme function (in template.php) for "function mytheme_views_view_list_myview($view, $nodes, $type) {"<br id="g_lh">we break up the $output displays via:<br id="l.t4"><br id="ay87">// artist nodepanel needs only 1 image<br id="vkkr">if (arg(0) == 'artists' && !is_null(arg(1)) && is_null(arg(2))) {<br id="qbgh"> (make look this way)<br id="r-qc">}<br id="iv.k"><br id="s20i">elseif (arg(0) == 'music' && !is_null(arg(1)) && !is_null(arg(2))) {<br id="p.k9"> (make look that way)<br id="g_jm">}<br id="q43d"></div>Another handy trick is sniffing for views in the node.tpl file via:<br id="k7t3"><br id="jb1h"><?php global $current_view; ?> <br id="vra:"><?php if ($current_view->name == 'some_view' || $current_view->name == 'another_view'): ?><br id="ukfh"><br id="hjml"> (whatever you want here)<br id="dyut"><br id="b7j2"><?php elseif ($teaser): ?><br id="k_ov"><br id="uboi"> (format the teaser)<br id="hcp2"><br id="fhhi"><?php else: ?><br id="fyjd"><br id="s-gz"> (full node view)<br id="qn1."><br id="jq_2"><h3 id="nsto"><span id="zr_u">Pane-specific node tpls</span></h3><h2 id="gb4m"><font id="ru33" size="2">Panels 2 has tools for very fine-grained theming control. Using our example above of Argument 2 - Video Node Title, there is a unique node tpl file for the video content type when called via this panel. Steps for using this method (in Drupal v 5.x) are as follows.</font></h2>In the panel/content tab for Node Name 2 Video - node content pane we have the Identifier set as:<br id="uxkr"><div id="pwm4" style="padding: 1em 0pt; text-align: left;"><img id="y56l" style="width: 578px; height: 100px;" src="File?id=ddc4hxf4_3gt5ncwcd"></div>Next, in your template.php file, specifically the section for _phptemplate_variables - $hook == 'node', add the following code:<br id="md9b"><?php<br id="uq.0"><p id="s01c"> if (!empty($vars['node']->panel_identifier)) {<br id="mqh5"> $vars['template_files'][] = 'node-'.$vars['node']->panel_identifier; <br id="mzs5"> }</p><p id="y-0j">?><br id="v49a"></p>...note that if your template.php file does not have a section for this check the <a title="Zen theme" href="http://drupal.org/project/zen" id="hvwt">Zen theme</a> for examples to copy.<br id="bxjv"><br id="byld">Finally, create your node tpl file. In our case this file is named: node-video_node_pane.tpl.php<br id="whbg">This can be themed as any other node tpl file.