17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1553 Views |
-
newbies help with adding images to main menu

6 November 2008 at 6:23am
I want to use images instead of text in main menu.
I add:
class Page extends SiteTree
{
static $db = array(
);
static $has_one = array(
'MenuImg' => 'Image'
);
...and
function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Images", new ImageField('MenuImg','Menu image'));...
than attach my image for menu.
but i can't get how to use it in my template.
i use <% control Menu(1) %> to get info about menu ($Title, $Content) but there is no $MenuImg there.
how i can use $MenuImg in my templates?
-
Re: newbies help with adding images to main menu

6 November 2008 at 9:31am Last edited: 6 November 2008 9:31am
So you've put $MenuImg in your template? It should work eg:
<% control Menu(1) %>
<% if MenuImg %>
$MenuImg
<% else %>
<!-- debug: menu image missing for page $Title -->
$Title
<% end_if %>
<% end_control %>
| 1553 Views | ||
|
Page:
1
|
Go to Top |


