Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Jul 2006
    Posts
    50
    Plugin Contributions
    2

    How to add a new section that only shows up on the index page but not others

    To start, I have copied the entire /includes/templates/default_template folder to /includes/templates/mytemplatefolder.

    the basic idea of what I want is a section that will only show up on the main index page of the site but not be there when viewing any other part.

    I thought of using a banner, but it doesn't need the banner click tracking. thought about using the define_main_page but when I move the code from tpl_index_default.php to tpl_header.php or to tpl_main_page.php it throws an error of not being able to open the file in the require(). To a certain extent I would like to have a secondary header that doesn't show up on any other page then the front page. I just seem to be having a hard time figuring this out and maybe I am over thinking it.

    In another CMS they have a variable that can be checked if it is the front page or not. Does ZC have something like this? If not, what would be the easiet way that you all can think of to test if the page being viewed is the front page or not?

    Granville
    Kirkham Systems, Inc.

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,761
    Plugin Contributions
    9

    Default Re: How to add a new section that only shows up on the index page but not others

    thought about using the define_main_page but when I move the code from tpl_index_default.php to tpl_header.php or to tpl_main_page.php it throws an error of not being able to open the file in the require().
    Using the "define_main_page does not require one to to MOVE CODE or touch the files at all.

    It is editable from the admin > tools > define pages editor

    So I guess I missed something that you might have infered or am completely lost as to your comment.

    Another Item that you may want to correct now is that one should only copy those files that are altered to the custom template override folders. Not all the files as you have stated. This will become increasingly apparent the first time you upgrade and now have 100's of files that you will need to check & merge instead of just the few that you should be altering.

    You should look in the template_default/css/for the css txt file, this outlines using css per page and will allow what you want , and again with out messing with CODE.
    Zen-Venom Get Bitten

  3. #3
    Join Date
    Jul 2006
    Posts
    50
    Plugin Contributions
    2

    Re: How to add a new section that only shows up on the index page but not others

    Quote Originally Posted by kobra
    Using the "define_main_page does not require one to to MOVE CODE or touch the files at all.

    It is editable from the admin > tools > define pages editor

    So I guess I missed something that you might have infered or am completely lost as to your comment.
    It seems that I did get you lost somewhere as it would seem that you missed the statement of "I would like to have a secondary header that doesn't show up on any other page then the front page". Please note that the header appears above the left and right sidebar columns. I'd like something that takes up the same space but will show up only on the front page but not the others.

    I thought I could move the define_main_page tidbit of code, since it only shows up on the front page, into the header area, or to another tpl file so that is shows up under the header but above the sidebars and body area. But in moviing the code that makes the define_main_page appear, an error occurs. So it would seem that the $define_main_pages is only ment to show in the body of any particular page.

    As for the problem, forget that I am messing with the code, forget that I copied the template, maybe I threw out a red herring and didn't know it. The most important question that I am putting forth is as follows, is there an easy way to put into the header something that will show up _only_ on the front page and not on any other page? If so, how?

  4. #4
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,699
    Plugin Contributions
    123

    Default Re: How to add a new section that only shows up on the index page but not others

    Did you try customizing

    ./includes/templates/template_default/common/tpl_main_page.php

    This is what you want.

    Where you're doing your customization, just check $body_id against "index"
    and you'll know if you're on the front page or not.

    Good Luck,
    Scott
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: How to add a new section that only shows up on the index page but not others

    Quote Originally Posted by graper
    To start, I have copied the entire /includes/templates/default_template folder to /includes/templates/mytemplatefolder.
    This, unfortunately, is a bad plan ...

    The idea behind the templates and overrides is to separte your code, changes, customization from the original files ...

    If you don't touch something, then you did not override or change anything so there is no need to place a file that is untouched into the templates and overrides directories ...

    The files are read as:

    Look for filename something ...

    1 is it in the templates and overrides directory?

    2 if not in 1 then get original file

    This means you can actually do an entire customization of a site by only touching relatively few files ...

    Examples of this are in the Downloads for the templates ...

    Language overrides are similar ... unless you changed the define statements in the language file it does not belong in the overrides directory ...

    If you change 1 letter ... then, yes ... it goes in the templates and overrides directory for that language file ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: How to add a new section that only shows up on the index page but not others

    If you look at the comments at the top of tpl_main_page.php, you will see examples of how to not display this or that on the main page. You can use the
    PHP Code:
    if($current_page_base == 'index' and $cPath == '') {
    your code here

    to display what you want only on the front page.

    Now, did you want another block just below the header? Or a different block in place of the header? This will affect the best way to proceed.

  7. #7
    Join Date
    Jul 2006
    Posts
    50
    Plugin Contributions
    2

    Re: How to add a new section that only shows up on the index page but not others

    Scott and Glenn, Thansk for the tips, those were the kind of answers I was looking for.

    Glenn, I am wanting to put in a second header, and as I look at the code I think I can put it in the tpl_header.php file, or in the tpl_main_page.php file under the require statement for the header. What do you think would be better?

    Linda, I appricate the word of caution and advice, but I had to get a grasp of what file to change to get what I want done, to do that I put in start and end comments in every single file and then looked at the page in a browser to see where things started and ended. Rather then leave them all in the default template files, I copied it all to a new folder. Believe me, the method I used gav mea greater comprehension of what files did what for the layout as well as what files I felt I needed to change. This way when another templates gets added into it, it wouldn't affect the default template, but only show the comments on my template. There was a method to my madness, but thanks for the insight on the override functionality of Zen Cart.

    Granville

  8. #8
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: How to add a new section that only shows up on the index page but not others

    I would put the "if" test with your display code at the bottom of tpl_header.php, after the very last line. I suppose it would work fine in tpl_main_page.php, but makes more sense to me in the header file.

  9. #9
    Join Date
    Aug 2006
    Posts
    16
    Plugin Contributions
    0

    Default Re: How to add a new section that only shows up on the index page but not others

    I'm trying to do the same thing but I'm not able to obtain what is in my intention:
    I've created an "index" folder in "templates/mytemplate/index" with "tpl_header.php" and "tpl_main_page.php" and made some code changes as explained on the files.

    The problem is that the custom content is shown on the Index and also when I click on the Categories. I only want my content shown only on the index.

    Can you help me? Thanks.

    This is an image of what I want to realize:
    http://img216.imageshack.us/img216/3495/mywo7.gif

  10. #10
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,699
    Plugin Contributions
    123

    Default Re: How to add a new section that only shows up on the index page but not others

    graper, either one is ok; just see where it fits best based on what you want to do.
    The great thing about the templating system is you can copy a single file to your template
    dir, try out a change, rename it to .tmp and you'll be right back to where you started.
    It's very easy to switch back and forth that way.

    beatdis, look at $cPath. You only want to use your logic when $cPath == ""

    Good luck to all,
    Scott
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 8 Apr 2015, 09:25 AM
  2. I turned off my the page that shows when you add a product?
    By RAM1001 in forum General Questions
    Replies: 1
    Last Post: 23 May 2009, 07:38 PM
  3. Want three columns on index page but two on all others
    By dinki in forum Templates, Stylesheets, Page Layout
    Replies: 19
    Last Post: 23 Feb 2007, 10:52 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR