Any page--<identifier>.tpl.php
will be used instead of page.tpl.php
for the url /identifier
. That is by design and the entire purpose of this system. This can be extended for deeper paths too: page--foo-bar-baz.tpl.php
for /foo/bar/baz
.
If you want certain content to appear on /identifier
, you have two options: Conditionally include the content or copy the content. What to choose depends on your situation.
Conditionally include: inside page.tpl.php
:
<div class="footer">
<?php if (arg(0) == "advertsindex"): ?>
<?php print theme("advertsindex_disclaimer"); ?>
<?php endif; ?>
</div>
Overrides: introduce a page--advertsindex.tpl.php
:
<div id="content">
<?php print $content ?>
</div>
When to choose what:
Only use conditional includes or conditional rendering when:
- The content to be included or excluded is small and shared. Patterns like `[large 20+ line of frontpage HTML][normal HTML] are very bad.
- The content to be included needs all sorts of fancy new variables pulled in. Patterns like are really bad. Drupals theme system is push (theme gets variables from modules) and never pull (theme requests parameters at modules).
In all other cases you'd use the overrides. And yes, that will include a lot of duplication, but that is by design and accepted as the default practice in Drupal. To avoid having to modify some HTML in 20+ files, "split" or "copy" them as late as possible.
A rule of thumb is that a conditional should be a few lines only and never require variables that are not available in the parent.