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>
  • 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>... – Christoph Farnleitner Feb 8 '18 at 10:01
  • PHP code does not work in CMS pages or CMS blocks. Why do you want to do so? – Mohit Kumar Arora Feb 8 '18 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. – DaveYme Feb 8 '18 at 10:52
  • I've made some edits to the question to try clear things up. – DaveYme Feb 8 '18 at 10:57
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(); 
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.