Author Topic: [TUT] Own menu and footer, respecting user's session.  (Read 14482 times)

0 Members and 1 Guest are viewing this topic.

Offline manurom

  • Full Member
  • ***
  • Posts: 227
    • View Profile
    • manurom's 4images templates
[TUT] Own menu and footer, respecting user's session.
« on: June 18, 2008, 11:09:39 AM »
Hello;
this subject has been discussed many times, and I did a collation of Chris' and KurtW's work and mine.

So, we need to have a custom menu on our template's left column, and whynot another one at his footer.
We could do it by a php include, but it brings strange problems on certain servers.
Let' do it respecting the 4images' script structure, and the sessions management.

First, let us edit the file includes/page_header.php. Just before the closing tag ?>, let us insert this:
Code: [Select]
//---------------------------------------------------------------------------------------------
//---- Template my_menu.html ------------------------------------------------------------------
//---------------------------------------------------------------------------------------------

$my_menu = $site_template->parse_template("my_menu");
  $site_template->register_vars(array(
    "my_menu" => $my_menu
  ));
  unset($my_menu);
 
//---------------------------------------------------------------------------------------------
//---- Template my_footer.html ----------------------------------------------------------------
//---------------------------------------------------------------------------------------------

$my_footer = $site_template->parse_template("my_footer");
  $site_template->register_vars(array(
    "my_footer" => $my_footer
  ));
  unset($my_footer); 


We have created two new tags that we can now insert in each of our HTML template pages: {my_menu} and {my_footer}.

Let us now create the two files that will be parsed by the tags we created.
We have to create a new file in templates/my_template/ folder, called "my_menu.html", with this example code:
Code: [Select]
<div align="center">
<table  width="100" border="0" align="center" cellpadding="0" cellspacing="0">
 <tr>
  <td width="100%" align="center" height="17" background="{template_url}/images/button.gif" ><a href="{url_home}" style="text-decoration: none"><strong>HOME</strong></a></td>
 </tr>
 <tr>
 <td width="100%" align="center" height="17" background="{template_url}/images/button.gif" ><a href="{url_home}?template=FAQ" style="text-decoration: none"><strong>FAQ</strong></a></td>
 </tr>
 <tr>
 <td width="100%" align="center" height="17" background="{template_url}/images/button.gif" ><a href="{url_top_images}" style="text-decoration: none"><strong>TOP IMAGES</strong></a></td>
 </tr>
 <tr>
 <td width="100%" align="center" height="17" background="{template_url}/images/button.gif" ><a href="{url_new_images}" style="text-decoration: none"><strong>NEW IMAGES</strong></a></td>
 </tr>
 </table>
</div>
<br>
As we work with the default template, you will need this picture:

Now, let us create a file templates/my_template/my_footer.html, with this example code:
Code: [Select]
<br /><div align="center">
  <table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr class="head1">
      <td width="25%" align="center" class="row1"><a href="{url_contact}">Contact us</a> </td>
      <td width="25%" align="center" class="row2"><a href="{url_cookies}">Cookies</a></td>
      <td width="25%" align="center" class="row1"><a href="{url_terms}">Terms</a></td>
      <td width="25%" align="center" class="row2"><a href="{url_wazza}">Etc...</a></td>
    </tr>
  </table>
</div>

That's the my_menu display:


and that's the my_footer display:


Keeping sessions alive:
4images is a sessions based script. Every visitor has an MD5 session number, while browsing your website.
Keeping sessions alive is not so difficult:
  • if you need to have a link to a core file, use links like: {url_home} to the homepage, {url_top_images}, to the top images page, and so on...
  • if you install any MOD depending on a PHP file, please do this (assuming that we call this PHP file my_mod.php):
    Open includes/page_header.php and find:
Code: [Select]
  "url_captcha_image" => $site_sess->url(ROOT_PATH."captcha.php"),and add after:
Code: [Select]
  "url_my_mod" => $site_sess->url(ROOT_PATH."my_mod.php"),
  • Then, you can link to "{url_my_mod}", without loosing your visitor's session ID.
  • If you create a custom template HTML page, FAQ.html, for instance, as described here: http://www.4homepages.de/forum/index.php?topic=4996.0, you will have to link to "{url_home}?template=FAQ"

Application:
Edit the file templates/my_template/home.html and find:
Code: [Select]
{endif random_image}insert just after:
Code: [Select]
{my_menu}
Now, find:
Code: [Select]
{footer}
and insert before:
Code: [Select]
{my_footer}Do the same thing in all HTML template files where you need to have your own menu displayed.

I hope that my explanation is clear enough.
Please feel free to ask about any case I could have forgotten.
« Last Edit: June 18, 2008, 01:08:42 PM by mawenzi »

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [TUT] Own menu and footer, respecting user's session.
« Reply #1 on: June 18, 2008, 01:08:17 PM »
hi manurom,

... thanks for this tutorial ...
... now we can fast link to this by a corresponding request as a hint ...
... I edited the little formating mistake ... ;)

mawenzi
Your first three "must do" before you ask a question ! ( by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline manurom

  • Full Member
  • ***
  • Posts: 227
    • View Profile
    • manurom's 4images templates
Re: [TUT] Own menu and footer, respecting user's session.
« Reply #2 on: June 18, 2008, 04:53:34 PM »
Thanks to you, mawenzi! :P