Jump to content

How to add color attribute next to Category name in Top Horizontal Menu


Recommended Posts

Hi Heovang,

 

I played with it a little bit and maybe this comes close:

Edit file /modules/blocktopmenu/blocktopmenu.php:

 

Go to function:

 

private function getCategory($id_category, $id_lang = false, $id_shop = false)

 

 

and change these lines:

 

 

...

if (!empty($is_intersected))

{

$this->_menu .= '<li '.$selected.'>';

$this->_menu .= '<a href="'.$category_link.'">'.$category->name.'</a>'; // delete this line

 

if (count($children))

...

 

 

into this:

...

 

 

if (!empty($is_intersected))

{

$this->_menu .= '<li '.$selected.'>';

 

if ($category->id_image != null) // change into this red part

$this->_menu .= '<a href="'.$category_link.'">'.' <img src="'._THEME_CAT_DIR_.

$category->id_image.'.jpg" width="20" height=20"> '.$category->name.'</a>';

else

$this->_menu .= '<a href="'.$category_link.'">'.$category->name.'</a>';

 

if (count($children))

...

 

 

Code is quite 'raw', and may need adjustment, but what it basically does is it displays the category picture in front of the category name.

If you then make a category 'Show by colour' and add subcategories like 'Green', 'Red', 'Blue' and add as their category image an image in the right colour, then it looks somewhat to what you want.

 

Give a look here (temporarily link, may be deleted soon)

http://prestatestshop.buymethai.com/index.php

 

at the topmenu I added the menu Shop by colour. In it's submenu I added the subcategories red and green as an example. Clicking on it will for example go to the subcategory 'green' page, where you can show all green products you have...

 

Does this look anything interesting??

 

Let me know,

Pascal

Link to comment
Share on other sites

  • 4 months later...
  • 3 weeks later...

Hi guys, thank you for this great code, it works perfectly for me.

 

Would you possibly know how to adjust the code so that it adds a static number at the end of the image name? For example, the code generates pictures called 123.jpg, 124.jpg, 125.jpg and I would like them to be called 123-2.jpg, 124-2.jpg, 125-2.jpg. It's because I need a bit different category and subcategory pictures in top menu from the ones I have everywhere else in the shop (I would, of course, adjust the new pics manually and upload them in the relevant folder). I know it might sound a bit crazy, but I can't find any better solution. Thank you. 

Link to comment
Share on other sites

mouse,

probably like this:

 

if (!empty($is_intersected))
{
$this->_menu .= '<li '.$selected.'>';

if ($category->id_image != null) // change into this red part
$this->_menu .= '<a href="'.$category_link.'">'.' <img src="'._THEME_CAT_DIR_.
$category->id_image.'-2.jpg" width="20" height=20"> '.$category->name.'</a>';
else
$this->_menu .= '<a href="'.$category_link.'">'.$category->name.'</a>';

if (count($children))
...

 

 

(Add blue -2 to code above) :-)

 

Explain a little more what you need, maybe there's another way to solve your problem?

pascal

  • Like 1
Link to comment
Share on other sites

Thanks again bro!

when you look at my web site .\,

there are topic like :-

NAIROBI EXCURSIONS

 

Itineraries

 

TANZANIA SAFARIS

 

FLASH EVENTS

 

the backgrond where these link are are in grey color, that what i want to change to brown. thanks

Edited by geolan (see edit history)
Link to comment
Share on other sites

Hi Geolan,

 

For the top menu:

In the file, /modules/blocktopmenu/css/superfish-modified.css  change this: (line 15 )

 

.sf-menu {
  1. margin10px 0;
  2. padding0;
  3. width980px;
  4. background#383838;     <--- change to desired code, like #884020
}
 
grey part, you can change in the same file (line 92)
.sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active {
  1. background#4E4E4E;    <-- change into desired code, like #AA6030
}
 
 
for the titles of other blocks :
edit file: /themes/default/css/global.css: (line 292)
.block .title_block, .block h4 {
  1. padding6px 11px;
  2. font-size12px;
  3. color#fff;
  4. text-shadow0 1px 0 #000;
  5. text-transformuppercase;
  6. background#383838;      <-- change to desired code, like #884020
  7. text-alignleft;
  8. font-weightbold;
}
 
for big block down below (the footer),
same file:  /themes/default/css/global.css:    (line 577)
#footer {
  1. color#fff;
  2. background#333;     <-- change to desired code, like #884020
}
 
for search box - button:
edit file: /modules/blocksearch/blocksearch.css   (line19)
 
#search_block_top .button {
  1. bordernone;
  2. border-radius0;
  3. color#fff;
  4. text-transformuppercase;
  5. backgroundurl(img/bg_search_submit.png) repeat-x 0 0 #101010;    <<--- delete front part, and change color, like #884020
  6. floatleft;
  7. height25px;
}

 

 

contact us back block (right below)

edit file: /modules/blockcontact/blockcontact.css (line 24)

#contact_block a {
  1. displayblock;
  2. margin-left60px;
  3. padding6px 8px;
  4. fontbold 10px Arial,Verdana,sans-serif;
  5. color#fff;
  6. text-shadow0 -1px 0 #000;
  7. text-transformuppercase;
  8.  
    -moz-border-radius3px;
  9. -webkit-border-radius3px;
  10. border-radius3px;
  11. backgroundurl(images/bloc_contact_a_bg.png) repeat-x 0 0 #000;    <--- delete front part, and change #000 to desired color, like #884020
}
 
 
Hope this helps,
pascal
  • Like 1
Link to comment
Share on other sites

Thank you so much PascalVG !! I'm gonna try and explain... I'm also including pics to illustrate. 

 

1) My problem is that I have black and white design. My category and subcategory images are black on white background which is OK. However, my top menu is black, so the font is white and the pictures should also be white... but they are black. :-) Actually they are black with white square background. When I use invert in css, the pics look the way I want, but this doesn't work for me in all browsers. And then another problem comes... problem No. 2

 

2) When I invert cat and subcat images in css, ALL cat and subcat pictures are inverted, of course, including the ones in my Color category which gives me totally mixed up colors. I can't think of any other solution than adjusting my pics manually (invert the black and white ones and keep the color ones the way they are). Pls see the pics to get a better idea of what I mean. 

 

Thank you for your help. 

post-280884-0-89907100-1378230631_thumb.jpg

post-280884-0-17942400-1378230643_thumb.jpg

Link to comment
Share on other sites

P.S. First quick thought is to make the top menu also white... (maybe with some black border lines to show item blocks, outside border etc.).

Is that possible/good idea??

 

Well, if possible, give me a link. Seeing the real site gives me some full picture...

pascal

Link to comment
Share on other sites

P.S. First quick thought is to make the top menu also white... (maybe with some black border lines to show item blocks, outside border etc.).

Is that possible/good idea??

 

Well, if possible, give me a link. Seeing the real site gives me some full picture...

pascal

 

Thank you Pascal, I'm grateful for your time and help! 

 

White background would not be the solution. :-( I will send you a PM with a link so that you see what the website looks like. Thanks again.  

Link to comment
Share on other sites

Hi Geolan,

 

For search and contact block:

 

I cannot see that you took out the first part of the lines yet:

 

for search box - button:
edit file: /modules/blocksearch/blocksearch.css   (line19)
 
#search_block_top .button {
  1. border: none;
  2. border-radius: 0;
  3. color: #fff;
  4. text-transform: uppercase;
  5. backgroundurl(img/bg_search_submit.png) repeat-x 0 0 #101010;    <<--- delete front part, and change color, like #884020
  6. float: left;
  7. height: 25px;
}

 

so in the end we have something like this:

 

#search_block_top .button {
  1. border: none;
  2. border-radius: 0;
  3. color: #fff;
  4. text-transform: uppercase;
  5. background:  #884020;    <<--- after we deleted front part, and changed color to #884020
  6. float: left;
  7. height: 25px;
}
 

 

contact us back block (right-below on page)

edit file: /modules/blockcontact/blockcontact.css (line 24)

 

#contact_block a {
  1. display: block;
  2. margin-left: 60px;
  3. padding: 6px 8px;
  4. font: bold 10px Arial,Verdana,sans-serif;
  5. color: #fff;
  6. text-shadow: 0 -1px 0 #000;
  7. text-transform: uppercase;
  8.  
    -moz-border-radius: 3px;
  9. -webkit-border-radius: 3px;
  10. border-radius: 3px;
  11. backgroundurl(images/bloc_contact_a_bg.png) repeat-x 0 0 #000;    <--- delete front part, and change #000 to desired color, like #884020
}
 

so in the end we have something like this:

 
#contact_block a {
  1. display: block;
  2. margin-left: 60px;
  3. padding: 6px 8px;
  4. font: bold 10px Arial,Verdana,sans-serif;
  5. color: #fff;
  6. text-shadow: 0 -1px 0 #000;
  7. text-transform: uppercase;
  8.  
    -moz-border-radius: 3px;
  9. -webkit-border-radius: 3px;
  10. border-radius: 3px;
  11. background: #884020;    <--- after we deleted front part, and changed #000 to #884020
}
 

 

So, for both, try to take the front part of the lines out (i.e. the image) and then change the colour.

Quite sure it works...

pascal

Link to comment
Share on other sites

Hi Geolan,

easiest way to do this is:

edit  /themes/default/css/global.css (line 1986):

#footer .block_various_links {
  1. padding15px 10px;
  2. displaynone;           <-- Add this. This will turn off the block with the links
}
 
 
Doing this, the three left over columns are not nicely spread out. To fix this, change in same file:
line 581:
.blockcategories_footer, #footer .myaccount, #block_various_links_footer,#social_block, #block_contact_infos {
  1. floatleft;
  2. width300px;     <-- change to 300px
}
 
and (line):
 
#footer .myaccount {
  1. padding15px 20px;    <-- change to 20px
}
 
That should do the trick,
pascal
Link to comment
Share on other sites

  • 1 month later...

ok i know

<img src="{$link->getCatImageLink($category->link_rewrite, $node.id, 'category_small')|escape:'html'}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />

.done

Link to comment
Share on other sites

  • 2 months later...

mouse,

probably like this:

 

if (!empty($is_intersected))

{

$this->_menu .= '<li '.$selected.'>';

 

if ($category->id_image != null) // change into this red part

$this->_menu .= '<a href="'.$category_link.'">'.' <img src="'._THEME_CAT_DIR_.

$category->id_image.'-2.jpg" width="20" height=20"> '.$category->name.'</a>';

else

$this->_menu .= '<a href="'.$category_link.'">'.$category->name.'</a>';

 

if (count($children))

...

 

 

(Add blue -2 to code above) :-)

 

Explain a little more what you need, maybe there's another way to solve your problem?

pascal

Pascal você e muito bom parabéns. 

Link to comment
Share on other sites

  • 1 year later...

Hello. I am trying to add colour options to attributes but I need to add a block to show the colour like red or black etc. I am not sure how to add this but I need to go one better. I need to show some colour as Red/White or Black/White and thus want to show a colour block with both colours.

 

Can anyone help me how to do this and please note I am really not handy with any code etc.

Link to comment
Share on other sites

Hi Bernard,

Not fully sure if I understand your request well. Do I understand correctly, that you want to add some color attribute to a product, with various dual-tone values, like red/blue, black/white?

 

If so:

- Create the attribute, like 'Color'

- Add a value

- Call the color value something like 'Black/White'

- instead of choosing a color from the color palette, you could choose a 'Texture' file, 

post-455771-0-88187700-1424799972_thumb.png

 

and make some small squares/rectangles graphics (gif/jpg) with both colors, like this:

post-455771-0-93799500-1424799811.gif

 

- Choose the graphics file and save

- do this for all dual tones you need.

 

 

Then:

- Edit/add a product, and make combinations which use these color values

- Go to front page, go to the product, and you will see the combined color shown:

post-455771-0-80690700-1424800472_thumb.png

 

Hope this is what you needed. If not, please tell us some more details, and maybe add some quick sketch or so.

 

pascal

Link to comment
Share on other sites

  • 8 months later...

Hi !

In PS 1.6 how can i add categories thum in mega menu ?

I have this code :

foreach ($pages as $page) {
                $cms = new CMS($page['id_cms'], (int)$id_lang);
                $links = $cms->getLinks((int)$id_lang, array((int)$cms->id));

                $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : '';
                $this->_menu .= '<li '.$selected.'>';
                $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>';
                $this->_menu .= '</li>';
            }

in getCMSMenuItems function.

 

Can you help me Pascal ?

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...