Im using the same HTML (below) in multiple views TPL files. Its used to make my own custom pager work with JavaScript.
At the moment im creating a TPL file for each view and then adding the full markup every time. This isnt great from a maintenance point of view as if I need to alter the HTML I will need to do so for every instance.
Is there a 'smarter' way to do this? For instance can I create a new TPL file to house this HTML and call the file in each views TPL file when I need it?
<div class="picThumb">
<div class="picThumb-inner">
<div class="picThumb-trig picThumb-trigLeft">Previous</div>
<div class="picThumb-trig picThumb-trigP1">1</div>
<div class="picThumb-trig picThumb-trigP2">2</div>
<div class="picThumb-trig picThumb-trigRight">Next</div>
</div>
</div>
The best option here — is to register a custom template via
hook_theme()
:Then put your custom HTML in the
custom-template.tpl.php
file.Then you can "include" it anywhere using
theme()
function: