Sunday, June 2, 2013

Adding a seperate Category Dropdown for the CSS MegaMenu for Zen cart

So you have installed the excellent CSS Mega Menu module from Picaflor Azul available in the zencart add-ons repostory, and you want to either limit the "Shop" dropdown to one category tree, or you want an additional seperate dropdown for a specific category, well here is how I did it.

The Usual Warning
As usual backup everything before you start, this doesn't touch the database (well it reads from it), so everything goes pear shaped you can fix it by replacing with the original files.

Step 1)

Find you category ID number for the category you with to display
The easiest way to do this is to hover over the category and the category number will appear in the link at the bottom of your page, in this case it is category 1379.

Step 2)

Now if you are wanting to limit the existing "Shop" dropdown to a specific category tree,  do the following step and then you are finished, if you want to make a separate dropdown for a category go straight to Step 3
Ok so you just want to limit the existing dropdown to one Category tree
Navigate to

includes/classes/categories_ul_generator.php

Around line 83, you will find the following function

function buildTree($submenu=false)
{
return $this->buildBranch($this->root_category_id, '', $submenu);
}

Edit it so it looks like this, adding in the correct category id for the your site

function buildTreebb($submenu=false)
{
$root_category_id = 1379;
return $this->buildBranch($this->root_category_id, '', $submenu);
}
Save your changes, upload the file

Next we will change the name of the dropdown so it doesn't say "Shop"
Navigate to

includes/templates/YOUR_TEMPLATE/common/tpl_mega_menu.php

around line 46 you will have the following line

<li class="categories-li"><a href="<?php echo zen_href_link(FILENAME_DEFAULT); ?>" class="drop"><?php echo HEADER_TITLE_CATEGORIES; ?></a><!-- bof cateories -->

Now we can do flash things and pull the category name from the database etc, but its a damn site faster to just type in the name of the category, like so

<li class="categories-li"><a href="<?php echo zen_href_link(FILENAME_DEFAULT); ?>" class="drop">Jenni Bowlin</a><!-- bof cateories -->
Save your changes, upload the file

Go to your website and test the dropdown (you may need to refresh the page first) and it should work fine

You are finished you don't need to read any further.

Step 3)


So here we are creating a seperate dropdown and leaving the "Shop " alone

First we navigate to this folder

 includes/classes/

Now we make a copy of the following file

categories_ul_generator.php

We will call it in this exercise

 categories_ul_generator_bb.php

Now we open the copy we have just made


includes/classes/categories_ul_generator_bb.php

 Around line 24, you will find the following line

  class zen_categories_ul_generator {
var $root_category_id = 0,

Change it to

  class zen_categories_ul_bb_generator {
var $root_category_id = 1379,



 Around line 39, you will find the following line

  function zen_categories_ul_generator($load_from_database = true) 

Change it to

  function zen_categories_ul_bb_generator($load_from_database = true)





Around line 83, you will find the following function

function buildTree($submenu=false)
{
return $this->buildBranch($this->root_category_id, '', $submenu);
}

Edit it so it looks like this, adding in the correct category id for the your site, and changing the name of the function to buildTreebb

function buildTreebb($submenu=false)
{
$root_category_id = 1379;
return $this->buildBranch($this->root_category_id, '', $submenu);
}
Save your changes, upload the file

The next step is to make the dropdown appear on your menu bar

Navigate to

includes/templates/YOUR_TEMPLATE/common/tpl_mega_menu.php

What we are going to do is copy the entire section of code that displays the "Shop" dropdown
in the file above, this should be lines 45 - 69 inclusive so thats all this code

<li class="categories-li"><a href="<?php echo zen_href_link(FILENAME_DEFAULT); ?>" class="drop"><?php echo HEADER_TITLE_CATEGORIES; ?></a><!-- bof cateories -->

<div class="dropdown_1column">
<div class="col_1 firstcolumn">
<div class="levels">
<?php

// load the UL-generator class and produce the menu list dynamically from there
require_once (DIR_WS_CLASSES . 'categories_ul_generator.php');
$zen_CategoriesUL = new zen_categories_ul_generator;
$menulist = $zen_CategoriesUL->buildTree(true);
$menulist = str_replace('"level4"','"level5"',$menulist);
$menulist = str_replace('"level3"','"level4"',$menulist);
$menulist = str_replace('"level2"','"level3"',$menulist);
$menulist = str_replace('"level1"','"level2"',$menulist);
$menulist = str_replace('<li class="submenu">','<li class="submenu">',$menulist);
$menulist = str_replace("</li>\n</ul>\n</li>\n</ul>\n","</li>\n</ul>\n",$menulist);
echo $menulist;
?>
</div>
</div>
</div>
</li><!-- eof categories -->

And then we paste it directly underneath so paste it in at about line 70 just above the manufacturers section

Now in you freshly pasted code you need to find the following so we can change the name of the dropdown

<li class="categories-li"><a href="<?php echo zen_href_link(FILENAME_DEFAULT); ?>" class="drop"><?php echo HEADER_TITLE_CATEGORIES; ?></a><!-- bof cateories -->

Now we can do flash things and pull the category name from the database etc, but its a damn site faster to just type in the name of the category, like so

<li class="categories-li"><a href="<?php echo zen_href_link(FILENAME_DEFAULT); ?>" class="drop">Jenni Bowlin</a><!-- bof cateories -->

Next we need to make the dropdown use our copied dropdown class so find this bit

require_once (DIR_WS_CLASSES . 'categories_ul_generator.php');
$zen_CategoriesUL = new zen_categories_ul_generator;
$menulist = $zen_CategoriesUL->buildTree(true);

and replace with this; note all 3 lines have changes, if you don't change them all you page will drop dead directly after the menu title

  require_once (DIR_WS_CLASSES . 'categories_ul_generator_bb.php');
$zen_CategoriesUL = new zen_categories_ul_bb_generator;
$menulist = $zen_CategoriesUL->buildTreebb(true);

Now save and upload the file, then go to your site and test it, you may need to refresh the page

Now you should have a dropdown menu next to the existing "shop" menu
Good Luck

Wednesday, January 16, 2013

Mail Chimp plugin for Zencart - adding extra fields

This is a little more tricky that you think, although once you have had a long read of mailchimps docs it is dead simple.

First of grab the Mail Chimp plugin  by SwGuy from the zencart plugins repository.

By default this only takes your email address, do for our example we will make it take first name and last name of your subscriber.

First step

Install the MailChimp Plugin as per the instructions given.

Second Step

Make sure your MailChimp Account is able to receive the extra fields

Third Step

Open includes/templates/template_default/sideboxes/tpl_mailchimp_sidebox.php

find this piece of code

$content .= ENTRY_EMAIL_ADDRESS;
$content .= '
';


Replace it with this

$content .= ENTRY_EMAIL_ADDRESS;
$content .= '
';
$content .= ENTRY_FIRST_NAME;
$content .= '
';
$content .= ENTRY_LAST_NAME;
$content .= '
';


Save the file

Fourth Step

In /includes/modules/your-template/create_account.php
 find this

mailchimp_add($email_address, $email_format);

and replace with

mailchimp_add($email_address, $firstname, $lastname, $email_format);


Fifth Step

In includes/functions/extra_functions/mailchimp_functions.php
Find this code (line 6-ish)

$merge_vars = array('');

Replace it with this

$merge_vars = Array(
'EMAIL' => $email_address,
'FNAME' => $firstname,
'LNAME' => $lastname
);



And thats all there is to it.

Sunday, December 30, 2012

Hair Removal - by Veet

Right, i am not or never will be a fan of shaving, but well i don't particularly like looking like Bill Baileys homeless brother, so i tend to shave irregularly, basically whenever i look in the mirror and think shit i look like a hippie.

So I looked at hair removal by wax but well being a wimp and reading the reviews here After i finished pissing myself laughing i decided that
a) I have no interest (not that i ever did) in manscaping my downstairs and
b) Its going to be painful on the face too.

So shaving is back on, until I feel lazy again, hell if it hurts to pull a plaster off I dread to think what a wax strip will do.



Visited by a Hedgepig

Hieronymous the hedgehog
Better maintain my average of 3 posts a year.

Anyway, a couple of weeks ago we got a visit from a very noisy little hedgehog, who ate all the cat food then followed me to the letter box and sniffed and rubbed against my slippers, then returned to feeding from the cats bowl, and looked a little miffed that there was no more food left (if a hedgehog can look miffed). He pretty much moved into the carport  for the week and only left when the cat started eating all her her food up.

I decided to name him Hieronymous the hedgehog after the famous painter Hieronymous Bosch, who painted the Garden of earthly delights which when i first saw it i thought was some weird trippy 70s album cover instead its a religious piece from the late 15th century, it is a weird painting and proof that some painters probably sniffed a bit too much of their own paints.



Shiny happy toothpaste

Okay being the renowned cheapskate that i am,I got some clearance toothpaste (shrek related) and when I squeezed it out it was clear green with glitter in it, which got me thinking why does all toothpaste have to be mint flavoured, and why not funky colours, okay i realise white looks clean, but you do rinse your mouth afterwards.

I mean why is there no cheese and onion flavoured toothpaste or pork scratching or lemon and honey, now theres a good combination the cleaning power of lemon with the soothing power of honey.
Mint is boring if you are going to use a herb why not parsley or caraway seed flavoured, but no pretty much every toothpaste uses plain old mint and its because we have been conditioned to believe mint is the smell of cleanliness, but then why aren't toilet cleaners mint scented instead they use food smells like vanilla or berry which just makes you hungry when you are taking a dump, quite frankly I'd rather have a minty fresh toilet and vanilla scented breath than the other way around.




Thursday, July 7, 2011

Divide by Cucumber

Shades of DiscWorld, visiting stuff today and saw this, who knew the techies at stuff had a sense of humour. see the text under the image

The original Link is here

 Of course from what i understand the error message should read

+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++

but then again that would probably frighten the conspiracy theorists.

Monday, May 16, 2011

Anyone else watching TED

I finally went on to the TED site

Fascinating video by Arvind Gupta, on making toys out of junk

His little story at the end is good to