Extra input field for topmenu items

Hi there, I’m new on this forum and new to CS Cart, but so far it looks great! I hope someone could point me in the right direction for solving a little problem I’m running into.



I’m trying to add an extra input field for topmenu items, a ‘subtitle’ that is displayed below the actual menu title. Example of a menu-items:

Toys - subtitle: Toys for cats, dogs and birds

Treats - subtitle: Delight your pet with a treat



I tried the following: in schemas > static_data > schema.php I added the following additional param for top menu (‘A’) (around line 97):


array(<br />
	'title' => 'menu_subtitle',<br />
	'type' => 'input',<br />
	'name' => 'param_5'	<br />
),
```<br />
<br />
Also, I added the language variable 'menu_subtitle' in the admin. <br />
<br />
However, the new input field does not show up in the admin section when I edit a topmenu item. I've tried clearing the cache of my browser.<br />
<br />
Is there a step I'm forgetting in making this work? (do I have to alter another file?).<br />
Or do I need to clear CS Cart cache files? (if so, how do I do this?)<br />
<br />
Thanks for any help! Michelle

You will definitely need to clear your cache (yourstore.com/?cc)

You will also need to modify the template that captures the info for the topmenu items as well as the area where the topmenu items are looped through and displayed.



The schema mod just gives you somewhere to store the static data.

Hi tbirnseth,

Thank you for your reply! Since I posted this I've already tried to clear the cache with ?cc, this did not make the extra field show up in the admin. I think I know how to alter the tpl file, but if i'm right this is only for the storefront view and does not affect the admin area.

Where can I find the template that captures the info for the top menu items?

Thanks for your help!

Try top.tpl which can be overridden with the hook “index:main_content”.

Thanks tbirnseth. This morning I looked at my code in schemas/static_data/schema.php with a fresh eye and I saw I simply misplaced a bracket. For those interested, I’ll explain what I did here.



The fourth param (popup direction) that was already in schema.php has an array in it, so there are two closing brackets -don’t know if that’s the right word for this character: ) -. I had put the fifth param (my new one) before that second bracket and because of that it just didn’t work (also didn’t show any errors).



After I changed that and cleared the cache, the extra input field showed up when I edited a top menu item. So I didn’t have to change any other files in order to make this work in admin. Of course, after this I did change skins/[my skin]/customer/top_menu.tpl to reflect the extra field on the storefront.



I added the schema.php with extra field to this post for reference. [attachment=4362:schema.php]



Now I’m going to figure out how to make this change using hooks instead of altering the core files :-).

schema.php

Just to understand CS Cart better - am I correct that there are no hooks in schemas/static_data/schema.php or skins/[my skin]/customer/top_menu.tpl that I could use? Does this mean that in this case, I do have to change the original files to get what I want? Will this be affected when upgrading?

Try creating addons/my_changes/schemas/static_data/schema.php and adding your definition to the file… I.e.


$schema['A']['additonal_params'] += array('title' => 'menu_subtitle', 'type' => 'input', 'name' => 'param_5');




It might work. It works for block schemas and settings. I've never seen it used for static_data, but I'd guess they use the same methods for all schema extensions.

[quote name='tbirnseth' timestamp='1311293529' post='117929']

Try creating addons/my_changes/schemas/static_data/schema.php and adding your definition to the file… I.e.


$schema['A']['additonal_params'] += array('title' => 'menu_subtitle', 'type' => 'input', 'name' => 'param_5');




It might work. It works for block schemas and settings. I've never seen it used for static_data, but I'd guess they use the same methods for all schema extensions.

[/quote]



Thanks! Would be great if this works, I'll give it a try and post my findings here.

Well, tried your suggestion but unfortunately I get this error:

Fatal error: Unsupported operand types in xxxx/public_html/addons/my_changes/schemas/static_data/schema.php on line 3

Might have something to do with the fact that the site runs on php5? (5.2.17)



The code I used (corrected small typo):

$schema['A']['additional_params'] += array('title' => 'menu_subtitle', 'type' => 'input', 'name' => 'param_5');

Also tried this:

$schema['A']['additional_params'][] = array('title' => 'menu_subtitle', 'type' => 'input', 'name' => 'param_5');

This makes the error disappear, but the extra field does not show up.



I'll continue to search for a solution. If I really can't get this to work I might just alter the original file and keep note of my changes for future upgrades.

Well, the good news is that the error means it's reading the file and applying the data.

You can look in the var/cache/ directory for the static settings file and then view it to see if your changes made it there and whether the structure looks correct based on other elements. At a minimum it would tell you the structure you need to assign to the 'additional_params' element.



This is a place where cs-cart support could really help out by simply adding a post with an example of the correct way to do this… But then there wouldn't be “but we can suggest our custom…”