Fork me on GitHub

Cannot override menu block template.  Bottom

Go to page 1 - 2 [+1]:

  • I'm currently working on a custom theme but I'm having trouble overriding the menu block template. I've created the custom template, menublock.htm, in the blocks folder of my theme. I then edited the master.ini file as shown in the documentation, here.

    Code

    page = master.html

    [blocktypes]
    extmenu = menublock.htm
    menutree = menublock.htm

    [blockpositions]
    left = block.html
    right = block.html
    center = centerblock.html

    [blockinstances]


    Unfortunately this just made the menu block disappear from my theme completely instead of applying the custom template. I created a home.ini, which is simply a duplicate of my master.ini at the moment, but I don't know the proper way to make Zikula recognise the file through pageconigurations.ini, so it's not helped the problem.

    The code for the custom template is as follows:

    Code

    <!--[foreach from=$menuitems item=item ]-->
        <!--[if $item.name != '' && $item.url != '' ]-->

            <tr>
                <td class="nav">
                    &raquo; <a class="nav" href="<!--[$item.url|pnvarprepfordisplay]-->" title="<!--[$item.title]-->"><!--[$item.name]--></a>
                </td>
            </tr>

        <!--[else]-->

        <!--[/if]-->

    <!--[/foreach]-->

    <!--[ if $access_edit ]-->

        <tr>
            <td class="block">
                <a href="<!--[ pnmodurl modname=Blocks type=admin func=modify bid=$blockinfo.bid addurl=1 ]-->#editmenu" title="<!--[ pnml name='_EMENU_ADDCURRENTURL' ]-->"><!--[ pnml name='_EMENU_ADDCURRENTURLSHORT' ]--></a><br />
                <br>
                <a href="<!--[ pnmodurl modname=Blocks type=admin func=modify bid=$blockinfo.bid fromblock=1]-->" title="<!--[ pnml name='_EMENU_EDITTHISBLOCK' ]-->"><!--[ pnml name='_EMENU_EDITTHISBLOCK' ]--></a>
            </td>
        </tr>

    <!--[ /if ]-->


    This is a preview of what I'd the theme to look like once it's done, so you can get some idea of what I'm trying to achieve with the custom block template.

    This is my first theme for Zikula so I'm still learning the system, and therefore it's likely I've just made a newbie mistake. Any help or suggestions you can give me would be much appreciated.

    Thank you. :)
  • Specifically where did you put the file. full path from the Zikula Root? I don't know that Caching will be the problem, as it does SOMETHING, but make sure the cache is cleaned out of the site.

    --
    Home Page | Find on Facebook | Follow on Twitter
  • The path is My Theme/templates/blocks/menublock.htm. I originally tried overriding it using the method decribed here but it had no effect. The documentation I linked above refers to paths for modules and doesn't have any examples for overriding blocks, so it's very likely I simply got the path wrong.

    Clearing the cache hasn't fixed the problem either, but thanks for suggesting it.
  • You don't actually have to edit the .ini file manually, you can do it via the theme admin area for your theme. That's how I always do it. That way I'm sure I'm pointing to a valid file. Could be a typo either in the file name of the ini file.

    --
    Home Page | Find on Facebook | Follow on Twitter
  • It's pretty weird icon_confused
    in BlankTheme we have a menublock.htm template too and it works like a charm...
    check it out and check how we work with out Zikula Theme Engine icon_wink
    Greetings and welcome to the Zikula Community Forums!

    --
    - Mateo T. -
    Mis principios... son mis fines
  • I checked all my file name spellings to make sure that wasn't the problem, which unfortunately it wasn't.

    I've downloaded BlankTheme, and at first glance it seems overly complicated for what I need, however I have had a look at the blocks and the menu block in particular. I noticed you used a block instance for the menu block, so I tried the same thing but with no success. I will take some time with it though and see if I can't figure something else out.

    I also checked to make sure the block was still active in Zikula, which it is.

    I'm toying with the idea of simply adding the buttons manually in my master.html file and doing away with the block altogether. Any new buttons I need I will just add manually through the code, which won't be a problem as this theme isn't for public release anyway. However, I will be stuck with the problem of how to show certain buttons only to users who are logged in or are administrators. For example, the Logout, Your Account and Administration links.
  • BTW, you are using the extmenu block and not the ("simple") menu block?

    --
    campertoday.nl, Module development, Dutch Zikula Community
  • Just about to ask that, Erik
    The simple menu block is just: menu

    --
    David Pahl
    Zikula Support Team
  • also remember that there is a hierarchy of overrides. I think the config directory has the highest priority, so if there is another template there, it will override your theme override (I think).
  • I added the entry for the simple menu block at the same time I tried the instanced one. That also had no effect.

    Could you possibly explain the override system in more detail for me please, craigh?
  • evilbluesmartie

    Could you possibly explain the override system in more detail for me please, craigh?


    It is in the code here

    But it looks like I may have been wrong and the theme is the higher priority. But take a look for yourself.
  • Theme is the first priority, followed by config, then default (read supplied).

    Clear out your caches. Also try with a simple block output instead of a complex output. Simply have the block output

    Code

    <h1>Test</h1>


    --
    David Pahl
    Zikula Support Team
  • I tried with a simple block output and it worked perfectly. It would appear that the override is working as it should, which means it's the code I'm using in the template itself which isn't working.

    The code I'm currently using is as follows:

    Code

    <!--[foreach from=$menuitems item=item ]-->
        <!--[if $item.name != '' && $item.url != '' ]-->

            <tr>
                <td class="nav">
                    &raquo; <a class="nav" href="<!--[$item.url|pnvarprepfordisplay]-->" title="<!--[$item.title]-->"><!--[$item.name]--></a>
                </td>
            </tr>

        <!--[else]-->

        <!--[/if]-->

    <!--[/foreach]-->

    <!--[ if $access_edit ]-->

        <tr>
            <td class="block">
                <a href="<!--[ pnmodurl modname=Blocks type=admin func=modify bid=$blockinfo.bid addurl=1 ]-->#editmenu" title="<!--[ pnml name='_EMENU_ADDCURRENTURL' ]-->"><!--[ pnml name='_EMENU_ADDCURRENTURLSHORT' ]--></a><br />
                <br>
                <a href="<!--[ pnmodurl modname=Blocks type=admin func=modify bid=$blockinfo.bid fromblock=1]-->" title="<!--[ pnml name='_EMENU_EDITTHISBLOCK' ]-->"><!--[ pnml name='_EMENU_EDITTHISBLOCK' ]--></a>
            </td>
        </tr>

    <!--[ /if ]-->


    If anyone can see any problems with the code here that may prevent it from working then please let me know. I'm going to have a look through myself and see if I can find the problem.

    Thanks. :)
  • Is the array assigned?

    Is pndebug on?

    --
    David Pahl
    Zikula Support Team
  • I'm afraid you'll have to elaborate on that for me, I haven't got a clue what you're talking about there. Remember I'm still fairly new to Zikula. :)

Go to page 1 - 2 [+1]:

  • 0 users

This list is based on users active over the last 60 minutes.