ThemeShaper Forums » Thematic

[closed]

Adding the custom menu to the top of blog page

(17 posts)
  • Started 7 years ago by proto
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. proto
    Member

    Hello All,

    I really like thematic but I have one problem. My menu is called in the top of page widgets (rather than the default access div) so I drop my custom menu into the thematic inbuilt widgets to display them at the top of the page or post. So far no problem.

    The problem I encounter is that I also want a blog but when I use the blog there's no widget to have the custom menu display at the top of the page. There's no widget for me to drop my custom menu for the top of the blog page, but there are ones for the pages and posts.

    Please can someone advise how I can get my custom menu to appear the top of my blog page as it appears on all my other pages that I call it?

    My website is here: http://www.freemantradingltd.com/about-us/

    Thank you in advance :)

    Posted 7 years ago #
  2. proto
    Member

    PS - if you click through all the pages you'll see the menu appears at the top but not on the blog page as there isn't a widget area for me to drop my custom menu at the top there.

    http://www.freemantradingltd.com/about-us/

    Posted 7 years ago #
  3. proto
    Member

    I think I've managed to solve this myself. But have 2 questions. Firstly I'll show you how I solved it:

    Knowing a child theme overrides it's parent I copied the exciting blog.php template (in thematic it's called "template-page-blog.php") I copied this file and saved and uploaded this file to my child theme root directory with one change. The Blog template calls the sidebar index-top as below:

    // calling the widget area 'index-top'
                	get_sidebar('index-top');

    I replaced this code to call the widget area page top with this code:

    // action hook for creating the 'page-top' widget area
       				widget_area_page_top();

    This worked successfully.

    So my two questions are,

    1: is there a better / more efficient way to do this for anyone who reads this forum in the future.

    2: The CSS styling for my menu active item doesn't work on my blog page (it's setup to be underlined on the active page. Yet this works on all other pages, I've tried inspecting the element and targeting the CSS a number of times so that the active menu item is light brown and underlined. What's more confusing is that the same CSS is working fine for every other active link on other pages.

    The website is here: http://www.freemantradingltd.com/blog/ (this is blog page where the underline and brown colour of the link does not show but notice how all other links show you what the active page is by being underlined and light brown in colour). Any advice appreciated on what I'm missing!

    Thanks in advance all :)

    Posted 7 years ago #
  4. widget? you don't need a widget to display your custom menu. i explain in the mega menu thread how to move the default menu (thematic will use your custom menu by default if it is defined in the 'primary' location in the dashboard)

    http://forums.themeshaper.com/topic/thematic-menus-demystified-1

    Posted 7 years ago #
  5. proto
    Member

    Hi Helga,

    I appreciate you trying to help me, thank you.

    I have no problem using the native custom menu in the dashboard but instead I'm using the "page-top" menu located at the top of the page not in the #access div. If you look at the my website you'll see the menu appears at "page-top" rather than in access div which through CSS I've told not to display at all because I want the menu at the page top rather than higher up where the #access div is. See my website if that doesn't make sense, notice how my menu at the page top is inline with my sidebar widget (if it was in the #access dive it would appear even higher which I don't want it to do):

    http://www.freemantradingltd.com/tunki-coffee/

    I figured out how to make my blog page also display the page top menu by copying and uploading the thematic "template-page-blog.php" blog to the root directly in my chlid theme but with one change, I called the custom menu to display at the page top. This worked fine.

    My question that remains is

    1: Really for someone who has the same problem in the future, was their a more efficient / easier way to achieve what I wanted?

    2: The CSS styling for my menu active item doesn't work on my blog page (it's setup to be underlined with the text appears in a light brown colour on the active page. Yet this works on all other pages, I've tried inspecting the element and targeting the CSS a number of times (see my style.css file) so that the active menu item is light brown and underlined. What's more confusing is that the same CSS is working fine for every other current page item active link on other pages.

    The website is here: http://www.freemantradingltd.com/blog/ (this is blog page where the underline and brown colour of the link does not show on the currently viewing page but notice how all other links show you what the active page is by being underlined and light brown in colour). Any advice appreciated on what I'm missing!

    Thanks in advance all :)

    Posted 7 years ago #
  6. middlesister
    Member

    I think was Helga was referring to is actually the answer to your first question: It is more efficient to simply move your access div to the place you want it to be instead of hiding it and display your menu in a widget area. Then you would not need to copy and edit the template-page-blog.php file either, but simply select the pre-existing template in your page edit screen.

    Posted 7 years ago #
  7. 1. as, i understand you want to move the menu and you don't want it to be in the normal place. please see the thread i linked above... Step 1 is how to remove thematic_access() from its current location in thematic_header and move it to a new hook. i can't see any reason to use a widget instead.

    2. that link is broken.

    Posted 7 years ago #
  8. proto
    Member

    Hello Helga & Middlesister,

    Thank you for your help.

    I tried moving my menu with the following code in my child theme "functions.php" file:

    // Remove the standard Thematic menu
    function remove_menu() {
    	remove_action('thematic_header','thematic_access',9);
    }
    add_action('init', 'remove_menu');
    
    // Moving the thematic menu to the widget area top
    add_action('widget_area_page_top','thematic_access')

    Unfortunately this does not seem to work. As before the blog page does not display my menu. I removed my child theme blog.php file and I think therefore it goes with thematic's default blog.php file and does not show the menu. Is this because:

    a) I've called the wrong menu location (see the code I'm using above) when I changed the location of the access menu?
    b) The blog.php file needs to be updated in my child theme with this new location?
    c) Some other problem?

    If you see the testimonials page on my website it displays fine: http://www.freemantradingltd.com/testimonials

    If you look at the blog page see that the menu has disappeared: http://www.freemantradingltd.com/blog

    Any thoughts greatly appreciated.

    Thank you :)

    Posted 7 years ago #
  9. proto
    Member

    All,

    I have made one further discovery trying to solve this. Thank you Helga and Middlesister for your assistance thus far.

    I've tried moving my access menu around using this thematic diagram showing the locations for widgets etc http://visualizing.thematic4you.com/

    To get my menu to appear in the right place for where I wanted to display (at the top of the page directly inline with the sidebar at the top of the content but not above the content, I changed the location (see post directly above). To have the menu display at the top of the page but inline with the rest of the content using "widget_area_page_top" does not work for the blog.php page for some reason? Anyone who reads this and knows why not please let me know.

    I then experimented with adding the #access menu to different locations in the thematic theme. I tried my menu to "thematic_abovecontent" and this floats slightly higher than the "widget_area_page_top" (where I'd like my menu to display ideally).

    // Remove the standard Thematic menu
    function remove_menu() {
    	remove_action('thematic_header','thematic_access',9);
    }
    add_action('init', 'remove_menu');
    
    // Moving the thematic menu above the header
    add_action('thematic_abovecontent','thematic_access');

    REMAINING QUESTION:

    So I left it as "thematic_abovecontent" and then amended my #access div to have margin of 15px from the top. This now displays a little further down and where I wanted it. Whilst this looks like I have what I wanted I wondered if anyone can explain why adding my #access menu (default menu) to "widget_area_page_top", where I'd like it to display, does not work, the menu disappears entirely on the blog page which calls the parent blog.php file template.

    Thank you!

    Posted 7 years ago #
  10. proto
    Member

    Just to clarify for anyone trying to get the same solution that I wanted I amended the display of the #access div via CSS targeting of the #access div as follows:

    #access {margin-top: 15px;}

    :)

    Posted 7 years ago #
  11. proto
    Member

    Ok one last update. The solution above is not ideal to say the least.

    As in firefox the menu does not appear correctly (suspect the browser renders slightly different to Chrome / Safari). Therefore I'm back to my original problem.

    PROBLEM

    If someone can tell me how to get my #access menu to display in the "widget_area_page_top" so it's cross browser compatible I would be grateful. I've tried using the functions.php code:

    // Remove the standard Thematic menu
    function remove_menu() {
    	remove_action('thematic_header','thematic_access',9);
    }
    add_action('init', 'remove_menu');
    
    // Moving the thematic menu above the header
    add_action('widget_area_page_top','thematic_access')

    Since the menu when it displays here is cross browser compatible. The only problem is that the blog page does not appear when use Helga's kindly suggested solution of removing the default menu location and placing it where I want "widget_area_page_top". Humpf!

    Anyone who can help me out of this maddening menu problem it would be great to hear from you...

    Posted 7 years ago #
  12. widget_area_page_top() is not a pre-defined hook. so similar to the hooks that are defined at the top of content-extensions.php (and prolly others) you need this:

    function widget_area_page_top() {
        do_action('widget_area_page_top');
    } // end widget_area_page_top

    but if you are creating a new hook for the menu, how does it show up across your entire site? why can't you add it to thematic_aboveheader or put it in thematic_header just in a different order?

    Posted 7 years ago #
  13. middlesister
    Member

    The reason your menu is not appearing on your blog page is that the page template is replacing the normal Page content with the index posts loop. No Page widgets would display either since the page template 'Blog' never calls the Page widget areas, and that is why your menu disappears on the blog page if you put it on the widget_area_page_top hook.

    I think that using 'thematic_abovecontent' is the right way to go if you don't want the menu in the header. If I paste your code above in a clean test install, the #access comes straight in line with the sidebar. If you look at your site in firebug or similar, you can see that this is the case for you as well. (Or give both a border-top and see that they are in line) But since the image in the sidebar is a bit lower down, you need the extra top margin on #access to move them in line visually. I don't understand why this is not an ideal solution. If you have cross browser issues, then the answer is in the css and not in what hook the menu is on. For me the menu looks the same in both safari and firefox. What issues do you see?

    Posted 7 years ago #
  14. proto
    Member

    Helga and Middlesister,

    Thank you both for your replies, you're a credit to this forum and I really appreciate your input in helping me to resolve my problem. I've tried with a clean install here and the top of the menu and the logo appear flush at the top, using the "widget_area_page_top.php" file:

    http://www.universalonewebdesign.com/bespoke-design-two/

    So my question is, Helga using the latest code you've kindly quoted to make the widget_area_page_top a hook:

    function widget_area_page_top() {
        do_action('widget_area_page_top');
    } // end widget_area_page_top

    if I add this onto the end of the code you kindly provided originally to remove the default thematic menu location:

    // Remove the standard Thematic menu
    function remove_menu() {
    	remove_action('thematic_header','thematic_access',9);
    }
    add_action('init', 'remove_menu');
    
    // Moving the thematic menu to the widget area top
    add_action('widget_area_page_top','thematic_access')

    will this make sure that my menu is hooked into the widget_area_page_top area? For simplicity, given how well it displays in this area I'd really appreciate the code that enables me to hook the default thematic menu into this area :)

    Middlesister - you're right, on a clean install it appears just fine, thanks for checking!

    Posted 7 years ago #
  15. proto
    Member

    PS - I should add I tried adding the function widget_area_page_top() to the code that removes and then re-attaches the menu to a designated area and it seemed to break my site, so the full code that allows me to attach the thematic menu to the widget_area_page_top would be greatly appreciated, thanks!

    Posted 7 years ago #
  16. just did a quick search and it seems that widget_area_page_top() is already a hook.. so when you add my code to make it a hook you probably run into a function that has already been defined.... which tends to cause the white screen of death

    i'd try changing the name of that hook to something totally different and non-thematic and see if that works.

    function kia_bacon_hook() {
        do_action('kia_bacon_hook');
    } // end kia_bacon_hook
    
    // Remove the standard Thematic menu
    function remove_menu() {
    	remove_action('thematic_header','thematic_access',9);
    }
    add_action('init', 'remove_menu');
    
    // Moving the thematic menu to the kia_bacon_hook
    add_action('kia_bacon_hook','thematic_access')

    then in your template use

    kia_bacon_hook();

    Posted 7 years ago #
  17. btw- i'm still not sure why you don't just add thematic_access to thematic_abovecontent()

    is your layout different on your one template page?

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.