Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 38
  1. #21
    Join Date
    Jan 2010
    Location
    Columbus, Ohio
    Posts
    19
    Plugin Contributions
    0

    Default Re: Inserting Code into tpl_header.php

    Ok, so here is what I did.

    I downloaded all the files in the folder template_default.
    I then uploaded them to the folder freetemplate1
    When asked to override files, I chose to skip all the file rewrites.

    So now - Freetemplate1 is a mirror of template_default.

    Now all I have to do is add the code to the tpl_header to call the function or whatever.

    I looked online for the past 3 hours and I really don't know what to do. I know I have to use this code:

    Code:
    <script language="javascript">var MenuFolderName="../jscript";</script><script charset="UTF-8" language="javascript" src="sftmp6arrays.js"></script><script charset="UTF-8" language="javascript" src="sfmenutmp6ie.js"></script>
    And somehow get it to be in PHP. I tried an html to php converter and that did not work. Is there any way possible - any of you know exactly what my php code should say?

    Thanks

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

    Default Re: Inserting Code into tpl_header.php

    Quote Originally Posted by drymetal
    I downloaded all the files in the folder template_default.
    I then uploaded them to the folder freetemplate1
    When asked to override files, I chose to skip all the file rewrites.
    This compplete copy/mirror will only make things harder later as you do not know what files have been changed

    What do you mean by "you choose to skip file rewrites??
    Quote Originally Posted by kobra
    You ONLY need to copy them to your template IF you change them from default
    Otherwise those in template_default are used
    Zen-Venom Get Bitten

  3. #23
    Join Date
    Jan 2010
    Location
    Columbus, Ohio
    Posts
    19
    Plugin Contributions
    0

    Default Re: Inserting Code into tpl_header.php

    I mean I didn't over write any files. I thought the other guy said I needed to have the directories mirror each other. I can edit easily phpnuke, joomla, phpbb and this...this is the most complicated, frustrating and impossible thing I have ever done in my life. This is day seven of not sleeping - I need to get this done so I can get paid for changing the stupid colors of the theme.

    I give up. There is no way this is possible or that this will ever make any kind of sense to me. How in the world can adding a stupid popup menu be so complicated? It is things like this that drive people to suicide.

  4. #24
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,266
    Plugin Contributions
    3

    Default Re: Inserting Code into tpl_header.php

    Well hopefully you are a LONG way from drastic action.

    I think you need to understand how the override system works, and what the purpose of the custom template is.

    In a fresh install of zencart, the system (certainly on the webshop side of the software) will compile the web pages using the PHP files in the TEMPLATE_DEFAULT template.

    So... if you have not created your custom template, then zencart will call (FOR EXAMPLE)...

    includes/templates/template_default/common/tpl_main_page.php

    ... when it builds up the main page.

    But you then decide you want to make some customizations to the main page, and this will require making some changes to:

    includes/templates/template_default/common/tpl_main_page.php


    So what you do is make a COPY of tpl_main_page.php

    (You would typically do this on your hard drive - because that is where you should do the editing as well)

    You then EDIT the file and save it on your hard drive.

    Now, that EDITED file must not overwrite the CORE (default) file.

    So, you would put it into the corresponding OVER-RIDES folder in your own template.

    I don't know what you have called your custom template, so I will refer to it as YOUR_TEMPLATE

    The location of your newly edited file will be:

    includes/templates/YOUR_TEMPLATE/common/

    ... but you may not yet have a folder called "common" inside YOUR_TEMPLATE...

    ... so you create one...

    And then you ftp tpl_main_page.php to THAT folder...

    includes/templates/YOUR_TEMPLATE/common/tpl_main_page.php



    The ORIGINAL file (from which you made a copy) is left untouched in its original location:-

    includes/templates/template_default/common/tpl_main_page.php


    ------------------------------------------------------------------
    Now... zencart is quite clever...

    It will look FIRST for your override file(s) when it starts to compose a page.

    If it finds the overrride, it uses the override file...
    includes/templates/YOUR_TEMPLATE/common/tpl_main_page.php


    If it does NOT find an override, it uses the CORE file
    includes/templates/template_default/common/tpl_main_page.php

    -------------------------------------------------------------------

    All you need do now, is what we explain above, regarding your js files.
    ------------------------------------------------------------------

    Finally, I hope you also realise that having the JS files is meaningless unless there is some PHP code somewhere that uses them...
    20 years a Zencart User

  5. #25
    Join Date
    Jan 2010
    Location
    Columbus, Ohio
    Posts
    19
    Plugin Contributions
    0

    Default Re: Inserting Code into tpl_header.php

    Ok so...come on laugh...it's funny in a sadistic kind of way...

    The templates don't work like other things. So if I edit a core file from the template_default folder (editing on my computer)- then I need to upload that to my custom template folder - in the correct location rather than over writing the original file.

    But that doesn't mean I need all the other files from the template_default folder. Only ones that have actually been changed by me. And the ones I've edited somehow on my computer - need to go in the custom template folder.

    So that means - if I add a file to the jscript folder - then that file needs to be in my custom template folder because that is different than the core stuff. And I don't need to copy the html_header.php file to my custom template folder - because I haven't done anything to it. So the core one still works?

    so then all I need to do - is the JS stuff like mentioned and have some php code that uses it. Hopefully for once I get the picture. lol

  6. #26
    Join Date
    Jan 2010
    Location
    Columbus, Ohio
    Posts
    19
    Plugin Contributions
    0

    Default Re: Inserting Code into tpl_header.php

    Or in other words...just making sure I got it...

    So where other programs like phpbb, you need to overwrite files or create new templates based off old ones (and upload the whole thing) - zen-cart is smart enough to let only changed files exist in a new template directory. So this way, the core files are always there and this makes creating new templates much easier once an idiot like me gets it.

  7. #27
    Join Date
    Jan 2010
    Location
    Columbus, Ohio
    Posts
    19
    Plugin Contributions
    0

    Default Re: Inserting Code into tpl_header.php

    Ok...maybe there is hope.

    I was able to get a flash file to be the banner rather than the graphic. (I found info on how to do it on the wiki here.)

    Ok - so now every file in my custom_template are only files that original author of the template made. (I've only edited his files...none of the core ones.)

    I created a jscript folder in my custom_template folder.

    I added two JS files to the jscript folder I created:

    jscript_sftmp6arrays.js
    jscript_sfmenutmp6ie.js

    The html_header.php file is in the template_default folder because I have not edited that.

    So now...I need to put a call function or whatever in the tpl_header.php file that is located in my custom_template/common/ directory.

    Any idea on what that would look like? :)

  8. #28
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,266
    Plugin Contributions
    3

    Default Re: Inserting Code into tpl_header.php

    Quote Originally Posted by drymetal View Post
    Ok so...come on laugh...it's funny in a sadistic kind of way...

    The templates don't work like other things. So if I edit a core file from the template_default folder (editing on my computer)- then I need to upload that to my custom template folder - in the correct location rather than over writing the original file.

    But that doesn't mean I need all the other files from the template_default folder. Only ones that have actually been changed by me. And the ones I've edited somehow on my computer - need to go in the custom template folder.

    So that means - if I add a file to the jscript folder - then that file needs to be in my custom template folder because that is different than the core stuff. And I don't need to copy the html_header.php file to my custom template folder - because I haven't done anything to it. So the core one still works?

    so then all I need to do - is the JS stuff like mentioned and have some php code that uses it. Hopefully for once I get the picture. lol
    Yes... you are on the right track...

    bear in mind that there are not over-ride systems for EVERY file in ZC. There are NO overrides in the ADMIN section of zencart, for example.

    The best way of knowing if an override is needed, is to look for classic folders.

    When you see a classic folder in a directory tree, you can be sure that an override folder of your own template is required.

    Typically, overrides apply only in the CATALOG side of the store, and usually in the following main directories' trees:
    • languages
    • modules
    • templates


    So just drill down into each folder and sub folder, and when you see classic, create your own template's folder at the same level in the tree.

    Even if these new folders are empty to start, they can be there. If you ever need to create an override file, you'll now see where it ought to live. (You may need to put a "blank" index.html file (or .htaccess) inside them to prevent directory listing in a browser... see what's inside a corresponding classic folder and ditto that content

    There are other places where you can put ADDITIONAL functional files such as in:
    includes/functions/extra_functions... These are not "overrides" though... they are ADDITIONAL files...
    20 years a Zencart User

  9. #29
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,266
    Plugin Contributions
    3

    Default Re: Inserting Code into tpl_header.php

    I should also clarify the status of ADDITIONAL files, as opposed to OVERRIDE files...

    If you store a new/modified file - even a JS file - in a template OVERRIDE folder, that file will ONLY EVER APPLY to that template...

    Let's say your custom template is called joe_bloggs ...

    In my post above, I show you that a joe_bloggs folder should exist at every level where there is a classic folder.

    Edited files and ADDITIONAL files are not the same thing...

    Your JS files are not actually overwriting anything - because in a standard install of zencart, there will be NO FILE called:
    jscript_sftmp6arrays.js

    So, if you put it into:
    includes/templates.template_default/jscript ...

    ... it will not be replacing or modifying anything... it is just an additional bit of JS that you want your site to use.

    -----------------------------------------------------

    NOW...

    question...

    WHY would you put
    jscript_sftmp6arrays.js into an override jscript folder, rather than the default jscript folder... ???

    answer ...

    If it is put into the DEFAULT jscript folder, its application is GLOBAL across ALL templates...

    If it is put into the CUSTOM jscript folder, its application is UNIQUE and EXCLUSIVE to that template...

    Let's say that in a few months' time, you don't like the look of your site and decide that this horrid joe_bloggs template needs to be replaced with another called jimmy_obama .

    If your JS files are located in the joe_bloggs jscript folder, they WILL NOT APPLY OR WORK when you switch to jimmy_obama

    ... they are SPECIFIC to joe_bloggs only.

    HOWEVER...

    If they are in the DEFAULT jscript file, their application is GLOBAL across all templates, so you could install template jimmy_obama and the jscripts would continue to function...
    20 years a Zencart User

  10. #30
    Join Date
    Jan 2010
    Location
    Columbus, Ohio
    Posts
    19
    Plugin Contributions
    0

    Default Re: Inserting Code into tpl_header.php

    Ok that all makes sense. So the override only applies in folders that have a CLASSIC folder.

    And the reason I put stuff into the custom_template folder is so that if I change templates - whatever changes I made will only apply to the old template.

    So this is useful for me - because there may be some changes that I want to be Global and to put in the template_default folder and there may be changes (like this menu) that I only want to apply to specific templates - in this case joe_bloggs...

    ...jimmy_obama? lol

    Ok that all makes sense now. Thank God. It actually sounds kind of better than template systems I am use to. As it seems like creating new templates would be far less complicated and easier to manage...

    I'm not clear on one last thing though. You said I need to put a call function in the tpl_header file. And I opened the:

    jscript_sftmp6arrays.js file and that doesn't have any functions in it.

    The other one:

    jscript_sfmenutmp6ie.js has over 20 occurrences of the word "Function (*)" *meaning there may be text in the parenthesis or not.

    Do I need to have a call function in the tpl_header that calls everyone of those functions? Or do I just have it call the two JS files?

    Lastly - how do I make it? There are about 500 different call function types online.

    jimmy_obama? lol

 

 
Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Inserting a string into PHP
    By bhensarl in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 5 Nov 2010, 11:46 AM
  2. PHP Question: Inserting code to refer to another .php file
    By datatv in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 17 Sep 2008, 10:24 PM
  3. Insert Image into Tpl_header.php
    By atheis in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 13 Aug 2008, 06:20 PM
  4. putting tpl_categories_css.php into tpl_header?
    By atracksler in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 26 Oct 2006, 08:59 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