Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Problem in linking footer

Go to End

4 Posts   6524 Views


Community Member, 19 Posts

13 May 2008 at 2:46pm

Hi all,

I wants to add links to footer of my website. I have created footerMenu.php like;
* Defines the FooterMenuPage page type
class FooterMenu extends Page {
static $db = array(
static $has_one = array(
static $allowed_children = array('Page');
class FooterMenu_Controller extends Page_Controller {

And added in includes;

<% if FooterMenu %>
<ul id="FooterMenu">
<% control FooterMenu %>
<li class="$LinkingMode"><a href="$Link" title="Go to the $Title page">$MenuTitle</a></li>
<% end_control %>
<% end_if %>

I also had added tab in behaviour of page like show only in footer menu and trying to call in under div footer like $footermenu but it didn’t work at all for me.

Can anyone guide me where I am making mistake? What I need to add more. Plz help me I am not too good at PHP.

Thanks in advance


Administrator, 685 Posts

13 May 2008 at 4:33pm

I don't know if a different page type is what you want here. It might be better to create a page with a particular URL; for example, footer-menu. Uncheck "Show in menus" on that page so that it doesn't show in the your main nav, and put all your footer items under that.

You can then put <% control ChildrenOf(footer-menu) %> into your template to get the children of that page listed as their own navigation menu.


Community Member, 37 Posts

13 May 2008 at 7:43pm

Edited: 13/05/2008 8:07pm

I took the following approach to footer links;

Create a file called FooterLinks.php and place it under mysite/code with the contents -
Note the line 'MyPage' => 'Page', if you want the Footer tab to appear on every Page then it will.

In Page.php add

static $many_many = array(
'FooterLinks' => 'FooterLink'

and add the following to function getCMSFields() in Page.php

$linksTablefield = new ManyManyComplexTableField(
'LinkText' => 'LinkText',
'LinkURL' => 'LinkURL',
'LinkID' => 'LinkID',
$linksTablefield->setAddTitle( 'A Link' );
$fields->addFieldToTab( 'Root.Content.Footer', $linksTablefield );

when you rebuild database you will have the tab for adding/removing and enabling footer links in the CMS.

You then need to display it in the template.
For this you could create a file and place it in the includes directory
This could have the following contents

<% if FooterLinks %>
<% control FooterLinks %>
<li><a href="$LinkURL" id="$LinkID">$LinkText</a></li>
<% end_control %>
<% end_if %>

You then need to place <% include Footer %> in the main
You can then style the list items as required.

I guess I could put this in as a recipe but it wasn't immediately obvious how I create a page in the docos. Anyone point me in the right direction?


Community Member, 19 Posts

14 May 2008 at 10:28am

Thank you both of you for your suggestions.
It worked easily with the option sam has provided. Thank you..........