Results 1 to 10 of 24

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Posts
    21
    Plugin Contributions
    0

    Default Display categories on tpl_index_default.php

    Hi,

    After doing many searches I cannot find the answer to this simple (?!) problem (although plenty of people confused with this part of ZC ;)):

    I want to display categories on home page and still be able to use tpl_index_default.php so that I can customize the home page.

    If I enable categories on home page by using 'Layout Settings ... Categories - Always Show on Main Page', then tpl_index_default.php is not used - which means I cannot customize the home page.

    I tried copying code from tpl_index_categories.php, but that didn't work.

    Can anyone point me in the right direction?!

    Thanks. :)

  2. #2
    Join Date
    Mar 2006
    Posts
    21
    Plugin Contributions
    0

    Default Re: Display categories on tpl_index_default.php

    Well, a few more hours and still haven't worked it out.

    If no one can tell me how to do this I guess I'll just have to hardcode the HTML for the categories - which obviously isn't a great solution.

    Anyone?

  3. #3
    Join Date
    Jan 2004
    Posts
    66,447
    Plugin Contributions
    81

    Default Re: Display categories on tpl_index_default.php

    You said you want:
    1. display categories on home page
    2. customize the home page

    What exactly do you mean by customize?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Mar 2006
    Posts
    21
    Plugin Contributions
    0

    Default Re: Display categories on tpl_index_default.php

    The main reason for this is so I can add some custom content below the categories, so the page will look like:

    [content from main_page in Define Pages Editor]
    [categories list]
    [New products for August]
    [specials]
    [custom content block added to template]


    Hope that makes sense :) (I'm developing on local server so can't give URL).

  5. #5
    Join Date
    Jan 2004
    Posts
    66,447
    Plugin Contributions
    81

    Default Re: Display categories on tpl_index_default.php

    How about extending the functionality a bit:

    in both of these files:
    /includes/templates/YOURTEMPLATE/templates/tpl_index_default.php
    /includes/templates/YOURTEMPLATE/templates/tpl_index_categories.php

    at the bottom, but above the final </div> add a line like this:
    PHP Code:
    <?php include($template->get_template_dir('tpl_my_index_content.php',DIR_WS_TEMPLATE$current_page_base,'templates'). '/tpl_my_index_content.php'); ?>
    Then make a new file at:
    includes/templates/YOURTEMPLATE/templates/tpl_my_index_content.php

    and in that file put your custom HTML code.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Mar 2006
    Posts
    21
    Plugin Contributions
    0

    Default Re: Display categories on tpl_index_default.php

    Thanks for the tip - I'll try it out :) ......

    ..... but that doesn't solve my problem (unless I'm missing the point - always possible!).

    I only want [custom content] on the home page which means I need to add it to tpl_index_default.php. If I add it to tpl_index_categories.php [custom content] will show on category listings (although I discovered only on categories that have sub-categories for some reason).

    So what I'm asking is - how do I include the code to display categories in tpl_index_default.php?

    Thanks for your patience. :))

  7. #7
    Join Date
    Jan 2004
    Posts
    66,447
    Plugin Contributions
    81

    Default Re: Display categories on tpl_index_default.php

    Quote Originally Posted by purkat
    The main reason for this is so I can add some custom content below the categories, so the page will look like:

    [content from main_page in Define Pages Editor]
    [categories list]
    [New products for August]
    [specials]
    [custom content block added to template]

    Hope that makes sense :) (I'm developing on local server so can't give URL).
    Quote Originally Posted by purkat
    I only want [custom content] on the home page which means I need to add it to tpl_index_default.php. If I add it to tpl_index_categories.php [custom content] will show on category listings (although I discovered only on categories that have sub-categories for some reason).

    So what I'm asking is - how do I include the code to display categories in tpl_index_default.php?
    Some things are still not fully clear.

    1. Zen Cart can be configured to show categories on the home page, or not.
    2. If you choose to display categories on the home page, then tpl_index_default.php is ignored

    The answers being given have been in keeping with the way Zen Cart works.

    However, what you haven't stated clearly is whether you "require" that your home page "have" your categories shown on it (which is not the default, but is what Ajeh was mentioning at one point).

    If you "must" have your categories listing show on the home page, then you need to enable the indicated switch.

    Then if you must add custom content "only" when no category is selected, then you'll need to edit as follows:
    /includes/templates/YOURTEMPLATE/templates/tpl_index_categories.php
    at bottom of file, add:
    PHP Code:
    <?php // display my custom content only on home page:
    if (!($current_page!='index' || (int)$cPath>)) {  ?>
    <div><h2>My Custom Content Goes Here</h2></div>
    <?php ?>
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Mar 2006
    Posts
    21
    Plugin Contributions
    0

    Default Re: Display categories on tpl_index_default.php

    That's it!! Thanks very much for sticking with it DrByte. :)) And thanks Ajeh for your help.

    I've told my boss to add some more to the donation that was on its way once this site gets finished. :)

  9. #9

    Default Re: Display categories on tpl_index_default.php

    Quote Originally Posted by DrByte View Post
    Then if you must add custom content "only" when no category is selected, then you'll need to edit as follows:
    /includes/templates/YOURTEMPLATE/templates/tpl_index_categories.php
    at bottom of file, add:
    PHP Code:
    <?php // display my custom content only on home page:
    if (!($current_page!='index' || (int)$cPath>)) {  ?>
    <div><h2>My Custom Content Goes Here</h2></div>
    <?php ?>
    Thanks DrByte, this code came in handy for me as well.

    I used it for News & Article Management Summary Module so that it would only appear on the Index page.

 

 

Similar Threads

  1. overrided the tpl_index_default.php page???
    By lieven23 in forum All Other Contributions/Addons
    Replies: 8
    Last Post: 11 Aug 2009, 04:32 PM
  2. tpl_index_default.php not showing in iexplorer
    By kellan4459 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 5 Dec 2008, 02:16 AM
  3. Replies: 4
    Last Post: 18 Jul 2007, 11:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg