0

Is it possible to create a pane template based on some kind of identifier? Just Like you can create a page--node--123.tpl.php file to render a different page for a node with nid 123, i'd like to make a panels-pane--pid--123.tpl.php to render a specific pane with pid 123 I have tried looking on google but i have found nothing about this possibility.

2 Answers 2

1

After a lot of working around & trial & error methods, I got this.

  1. Copy your "panels-pane.tpl.php" in your current theme's template directory.
  2. include dpm($pane); in a php tag. This will give u the list of all the panes on ur current panel page.
  3. Note down the pid ($pane->pid) here.

    • If you are looking for a particular page the unqiue identifier for that whole page would be did ($pane->did) which is the display id.
    • Basically, every panel page has a unique did (display id) & different pid (pane Id) for all the panes on that particular page.
  4. Now in your "panels-pane.tpl.php" in the div code block with class="pane-content" you could write a php code like

    if($pane->pid=='some id' & $pane->did=='some id') {
    //modify your pane data from the variables at $pane->configuration & store in $content.
       $content = your modified data;
       print render($content); // render this pane with my modified data
    else
    print render($content); // (and) render other panes as normal
    }
    
1
  • Thanks, that's quite a dirty solution but i get the idea. It'll do
    – valepu
    Commented Nov 19, 2014 at 14:11
0

when you use the dpm($pane), you can also use the $pane->type variable to get the value of pane type & use this to create a separate template file that affects all the panes of this type only.

for example: In my scenario, i had added custom-content on pane. (Pane > Add content > Add custom content) So i had a few of such content-panes, which i wanted to be wrapped around in different html divs for structuring.

In my case, on dpm($pane) this $pane->type value was "custom". (This could be view, block, etc, as per the pane data) So I created "panels-pane--custom.tpl.php". This will affect all the panes of this (custom) type. Further, as my above answer, for a given panel node, I know my page's display id ($pane->did).

So use an if condition on this display-id & further you can use if / else-if / switch on $pane->pid for altering a particular pane.

    if($pane->did=='some-id') {
       switch($pane->pid) {
       case 'pid1' : some code stored into $content & then - print render($content); break;
       case 'pid2' : some code stored into $content & then - print render($content); break;
       default     : print render($content);
      }
    }

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.