Results 1 to 7 of 7
  1. #1

    help question Adding custom function, calling custom code from pages.

    Hi Zen Community,

    Hoping you can help me improve my ZenTagCloud code so that it meets community standards, and can be released as a beta version.

    1. I have taken a zen cart function, renamed it and modified it. Where is the best place to put custom functions? The original function was zen_get_categories(), its now named zen_get_categories_names().

    2. Since the Tag Cloud could be invoked on multiple pages. Where is the best place to put the core code, and how would I call the code from, say, the home page? Or perhaps the products page?

    3. In future revision of the add-on I would like to offer configuration settings through the admin section. How is the best achieved?

    4. Is there anything else I should know about making a add-on?

    I'm sure these question are probably answered elsewhere and would appreciate being pointed in the direction of the resources.

    Many thanks for your assistance,

    Proud to be part of the community.

    Nathan

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Adding custom function, calling custom code from pages.

    a. Plugging in functions can be done by creating a *.php file in the /includes/functions/extra_functions/ folder containing just the functions.
    Ref: http://www.zen-cart.com/wiki/index.p...included_files

    b. Classes can be loaded via the initSystem infrastructure, documented here:
    http://www.zen-cart.com/wiki/index.p...als#InitSystem
    They can even be instantiated there too if appropriate. However, in your case you probably don't want to instantiate until you have context with which to do so on a given page.

    c. With classes loaded/declared, and with functions loaded/declared as above, then in your individual pages where you require your class to generate output, you simply call it where you want it to appear - typically in a template file ... ie: /includes/templates/YOURTEMPLATE/templates or even the tpl_header in /includes/templates/YOURTEMPLATE/common


    PS: It's not advisable to use only the "short" <? tag to start a PHP file. It's best to use the longer, more compatible <?php tag instead.
    .

    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.

  3. #3

    help question Re: Adding custom function, calling custom code from pages.

    Thanks DrByte, was very pleased to get your assistance as such a New Zinner.

    Ok, I'm reading over the Developers API > InitSystem > The Control Array section and can't get my head around it. It states:

    Control arrays are automatically loaded from the directory /includes/auto_loaders. Every *.php file within that directory is expected to have a certain structure. In v1.3.0 we use a file called config.core.php as the main file for governing application_top.php. Third party developers can add their own control array files.

    It then goes on to say how to structure the file, and what to put in it. However I'm not clear on:
    a. where to put the file
    b. what to call the file

    I assume that the info is there, beceause others have got contribs working but I'm at a loss. Any help appreciated.

    On the up side:

    I've moved the new functions to the correct folder and the add on still works. Next I'll move the CSS code to the correct folder. And then that just leaves the class file.

    Thanks to anyone willing to share this knowledge.

    Nathan

  4. #4

    Default Re: Adding custom function, calling custom code from pages.

    [FONT=Verdana]Doing a search for "$autoLoadConfig[" yeilded results in only two files:
    - zen/admin/includes/auto_loaders/config.core.php
    - zen/includes/auto_loaders/config.core.php

    Assuming I add the code to one of those files, won't the changes get overridden with a future upgrade? And is it normal for a contrib install to ask the user to modify this file? I don't want this contrib to be responsible for damage to any system in the future.

    Thanks again.
    [/FONT]

  5. #5
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Adding custom function, calling custom code from pages.

    While you would use the structure of the config.core.php file as an example, you would put your own auto-load instructions in a file named config.YOURAPPNAME.php in the /includes/auto_loader/ folder.
    .

    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

    Default Re: Adding custom function, calling custom code from pages.

    Hi Dr,

    Thanks for the clarification, I must still be missing something. I tried a few things and they didn't work. I put the following code in a file called 'config.zentagcloud.php' and put the file in the includes/overrides directory. However the class is not loaded, and I receive a php error 81 (i think) when visiting the tagcloud. Did I miss something? Perhaps permission on the file?

    I would also appreciate any input you have DrByte for the tag cloud. At the moment I'm thinking of parsing the meta keywords for each item/category. And developing a way to track successful tags upon click. I also intent on having a global tag cloud, and local tag cloud for each product/category. So that the tag cloud information will more reliant to the user.

    Any suggestion/pointers encouraged early on in the development! ;)

    Cheers Nathan.

    Code:
    <?php
    
    /**
    
     * autoloader array for zentagcloud.php
    
     */
    
    if (!defined('IS_ADMIN_FLAG')) {
    
     die('Illegal Access');
    
    } 
    
    
     /**
    
     * Load ZenTagCloud class.file 
    
     */
     
       $autoLoadConfig[5][] = array('autoType'=>'class',
    
                                    'loadFile'=>'zentagcloud.php');
    ?>
    Last edited by madteckhead; 12 Jun 2007 at 05:00 PM. Reason: because I'm only human

  7. #7
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Adding custom function, calling custom code from pages.

    You might try this approach instead:
    Attached Files Attached Files
    .

    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.

 

 

Similar Threads

  1. v139g Adding custom code to a specific Ez Page
    By stephenconnolly in forum General Questions
    Replies: 3
    Last Post: 7 Oct 2012, 12:19 AM
  2. adding a custom item code (field)
    By keneso in forum General Questions
    Replies: 4
    Last Post: 30 Jan 2010, 01:12 PM
  3. Adding custom Tracking code into footer?
    By blakemiller in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 17 Jan 2010, 04:54 PM
  4. Custom Javascript Calling images from unsecure folder
    By CoolCarPartsOnline in forum General Questions
    Replies: 0
    Last Post: 29 Dec 2008, 08:59 AM
  5. Replies: 6
    Last Post: 4 Mar 2008, 07:52 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