Results 1 to 10 of 17

Hybrid View

  1. #1
    Join Date
    Oct 2007
    Posts
    9
    Plugin Contributions
    0

    application error Re: category descriptions on index page

    Alright, so I poked around and figured my best bet was to run my own query. So I did this:

    $categories_description_query = "SELECT categories_description
    FROM categories_description
    WHERE categories_id = :categoriesID";

    $categories_description_query = $db->bindVars($categories_description_query,
    ':categoriesID', $categories->fields['categories_id'], 'integer');
    $categories_description = $db->Execute($categories_description_query);

    Then later I can call $categories_description->fields['categories_description']

    Hope this helps anyone else stuck with the same problem.

    Cheers,
    cw

  2. #2
    Join Date
    Oct 2007
    Posts
    23
    Plugin Contributions
    0

    Default Re: category descriptions on index page

    You put that query in categories_row? (I've been trying to get this to work as well, I'm not sure how I missed your post. I think I've looked at all the others that are close...)

    Forgive my ignorance, but don't you have to have passwords to access the DB information?

    I will play with this, but if someone knows WHY it works and would share that knowledge, it would be a boon to the tiny bit of my brain that tries to program...

    Thanks

  3. #3
    Join Date
    Oct 2007
    Posts
    23
    Plugin Contributions
    0

    Default Re: category descriptions on index page

    I've tried to run your query, and I cannot figure out where to put it to make it work.
    Last edited by LittleR; 30 Oct 2007 at 03:54 PM. Reason: too much whining.

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

    Default Re: category descriptions on index page

    Forgive my ignorance, but don't you have to have passwords to access the DB information?
    ZenCart provides the opening of the DB with the credentials that are in your configure.php file.

    there is a division between files that obtain data (categories_row.php & others) and files that use this information for display - mostly tpl_ files. So this is 2 step. Insure that the data has been made available. Then in aas associated tpl_ file display this data.
    Zen-Venom Get Bitten

  5. #5
    Join Date
    Oct 2007
    Posts
    23
    Plugin Contributions
    0

    Default Re: category descriptions on index page

    That is what I needed. Thanks!

  6. #6
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    163
    Plugin Contributions
    0

    Default Re: category descriptions on index page

    So what was the final solution to accomplish this?

  7. #7
    Join Date
    Jan 2005
    Location
    NY
    Posts
    149
    Plugin Contributions
    0

    Default Re: category descriptions on index page

    Has anyone actually gotten this working yet?

  8. #8
    Join Date
    Oct 2007
    Posts
    23
    Plugin Contributions
    0

    Default Re: category descriptions on index page

    I did not notice the bumps on this, sorry.

    In category_row.php, around line 40, you will find something like this code (I'll call this "firstbit" for reference):

    $list_box_contents[$row][$col] = array('params' => 'class="categoryListBoxContents"' . ' ' . 'style="width:' . $col_width . '%;"',
    'text' => '<a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . zen_image(DIR_WS_IMAGES . $categories->fields['categories_image'], $categories->fields['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) .' '. $categories->fields['categories_name'] . '</a><br />');

    Right above the "firstbit", paste these 3 lines from CrackWilding:

    $categories_description_query = "SELECT categories_description FROM categories_description WHERE categories_id = :categoriesID";

    $categories_description_query = $db->bindVars($categories_description_query,':categoriesID', $categories->fields['categories_id'], 'integer');

    $categories_description = $db->Execute($categories_description_query);

    Then you will need to change the "firstbit" to display the description like so:

    $list_box_contents[$row][$col] = array('params' => 'class="categoryListBoxContents"' . ' ' . 'style="width:' . $col_width . '%;"',
    'text' => '<a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . zen_image(DIR_WS_IMAGES . $categories->fields['categories_image'], $categories->fields['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) .' '. $categories->fields['categories_name'] . '</a><br />'. $categories_description->fields['categories_description'].'<br />');

    Does that help?

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

    Default Re: category descriptions on index page

    You should be able to get the categories_description field in $categories by adding it to the original query in /includes/modules/pages/index/main_template_vars.php (no override path available).
    Add , cd.categories_description to the query in two places, line 96 and line 110:
    Code:
            $categories_query = "SELECT c.categories_id, cd.categories_name, c.categories_image, c.parent_id, cd.categories_description
    You should now be able to use $categories->fields['categories_description']


    Note that the previous standalone query in posts 7 & 16 would not work if your database has table prefixes, or you use multiple languages. The query in main_template_vars accounts for those cases.

 

 

Similar Threads

  1. Category descriptions on the main page?
    By mpayson in forum Templates, Stylesheets, Page Layout
    Replies: 11
    Last Post: 15 Mar 2011, 12:17 AM
  2. Category descriptions on Main Page
    By webrob in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 13 Mar 2010, 07:22 PM
  3. Category Descriptions on Main Page
    By tomkeyes in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 22 Oct 2009, 07:45 PM
  4. Category descriptions on Index page
    By uyeahu in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 3 Mar 2009, 07:16 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