0

In my current job we control the menu from a static block. But I didn't build or edit this.

I am building my own site and want to use the same feature. But i'm not a PHP Dev

I did look at this ticket How to use custom navigation menu instead of categories menu

and I did edit the file here app/design/frontend/rwd/default/template/page/html called topmenu.phtml

I removed this code

<?php if($_menu): ?>
<nav id="nav">
 <ol class="nav-primary">
 <?php echo $_menu ?>
 </ol>
</nav>

and added my own static block code {{block type="cms/block" block_id="top-menu"}}

But it doesn't work.. this code just appears as code on the top of the page.

This is what the code I have looks like now on the topmenu.phtml page

<?php $_menu = $this->getHtml('level-top') ?>
{{block type="cms/block" block_id="top-menu"}}

What can I do to give this ?

Thanks.

EDIT Just to be clear.

I've added normal HTML code to my static block. The issue is making the static block and the html account appear in the menu.

I've not added PHP code anywhere. I've removed the following code from the topmenu.phtml page

<?php if($_menu): ?>
<nav id="nav">
 <ol class="nav-primary">
 <?php echo $_menu ?>
 </ol>
</nav>
asked Feb 8, 2018 at 9:48
4
  • 1
    Please read the posted link again and make your changes accordingly. Nothing says you must put PHP code into your static block (as this does not work). Your static block is supposed to contain a structure like <ul><li>...</li>... Commented Feb 8, 2018 at 10:01
  • PHP code does not work in CMS pages or CMS blocks. Why do you want to do so? Commented Feb 8, 2018 at 10:01
  • Yes i know. I didn't say I added PHP code to the static block. I added HTML. I think you need to re-read what I said. I want to control the menu from a static block. I'm not adding php code anywhere. I've removed PHP code from the topmenu.phtml page and added my static block code. Commented Feb 8, 2018 at 10:52
  • I've made some edits to the question to try clear things up. Commented Feb 8, 2018 at 10:57

1 Answer 1

0
{{block type="cms/block" block_id="top-menu"}}

The above code will work only in static block or cms page. To add static block in phtml file you have to use below code

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('top-menu')->toHtml(); 
?>
answered Feb 8, 2018 at 11:01
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.