Maian Script World on Facebook Maian Script World on Twitter Maian Script World - Latest News Maian Script World on YouTube Maian Script World on LinkedIn


Please Read

You are required to register before you can post. This is via a custom verification system. Please post any problems you are encountering here and I`ll do my best to respond as soon as I can. Please note that a reply WILL be posted to all queries, so do not double post. There are no guarantees when a reply will appear but I do my best to answer all within 3/4 days max. Bumping topics won`t make the slightest difference.

IMPORTANT: Posts in English ONLY please, thank you! Any other languages will be ignored and your message deleted.
SEARCH: Use the search option to see if your question has been answered on the forum before. Or check the relevant script docs.
CUSTOMER: If you have purchased a commercial version of any of my software, using the contact option at the licence centre ensures a faster response.
AUTO DELETION: Accounts older than 5 days, with no posts or topics, are automatically deleted. Only register if you are thinking of posting.
PRIVATE MESSAGES: Private messages are currently disabled.
LINKS: Any links posted are 'NOFOLLOW' and will not be picked up by search engines.

You are not logged in.

#1 14-03-2011 10:15:44

duceduc
Members
From: Japan
Registered: 25-05-2010
Posts: 359

create new.tpl file to show only in header when page.tpl.php is called

I want to have a 'new.tpl' file to show up in the header only whenever a certain page.tpl.php is called. What would the php code be?

Offline

#2 16-03-2011 04:01:03

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,069

Re: create new.tpl file to show only in header when page.tpl.php is called

Well, you can`t specifically know when a tpl file is loaded, but you can check it using the url and then work around that.

So, lets say you wanted to load a link in the header, but only when the contact page is visible. You would add the following somewhere in the header tpl file:

if (isset($_GET['cmd']) && $_GET['cmd']=='contact') {
// show link..
}


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
David Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

#3 18-03-2011 05:50:56

duceduc
Members
From: Japan
Registered: 25-05-2010
Posts: 359

Re: create new.tpl file to show only in header when page.tpl.php is called

What if I want to have a div block shows only when the contact page is loaded?
I tried wrapping your code in a div but get error. Do I need to enclosed it with '<?php ?>'?

if (isset($_GET['cmd']) && $_GET['cmd']=='contact') {
<div>
something......
</div>
}

I am using this method but prefer this one since it is much cleaner.

Offline

#4 18-03-2011 08:38:04

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,069

Re: create new.tpl file to show only in header when page.tpl.php is called

You need to break out of php mode when using code like you are doing. PHP code must be between php tags.

<?php
if (isset($_GET['cmd']) && $_GET['cmd']=='contact') {
?>
<div>
something......
</div>
<?php
}
?>


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
David Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

#5 19-03-2011 07:24:30

duceduc
Members
From: Japan
Registered: 25-05-2010
Posts: 359

Re: create new.tpl file to show only in header when page.tpl.php is called

Got it. Thx.

Offline

#6 21-03-2011 01:11:05

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,069

Re: create new.tpl file to show only in header when page.tpl.php is called

Great. smile


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
David Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

Board footer

2Checkout.com is an authorized reseller of goods and services provided by Maian Script World.© 2003-2013 David Ian Bennett. All Rights Reserved | Forum: FluxBB

Privacy Policy | Refund Policy