[ic] Action Map - basics?

music at labyrinth.net.au music at labyrinth.net.au
Thu Aug 4 05:12:25 EDT 2005


>I am adding a 'News' section to our Interchange store.
>
> I have successfully added a new MySQL table 'News' and set this up in the 
> UI so entries can be added.
> 'News' items are categorised by Categories similar to our Product 
> categories.
> For simplicity the 'News' table fields look something like:
>
> code    category    newscontent
> 1    Hammers    New hammers released by Acme etc.
> 2    Nails    Acme releases line of titanium compound gang nails. etc
> 3    Nails    New tests show hand hammered nails five times stronger than 
> gun nails etc
>
> I have been able to display News items with a news.html page that uses 
> [query] tag and SQL statements.
>
> However, I thought that this might be a good opportunity to use ActionMap 
> functionality.
>
> I think I have read every ActionMap post in the archives and docs however 
> I am struggling getting this to work.
> Before I go on this is my first ActionMap and I admit I do not fully 
> understand the function.
>
> I am hoping to be able to display news items using URLs as follows:
>
> www.domain.com/storename/news/Hammers
>
> or
>
> www.domain.com/storename/news/Nails
>
>
> My ActionMap (added to catalog.cfg) looks like:
>
> ActionMap  news  <<EOR
> sub {
>        my ($action, $category) = split ('/', shift);
>        $CGI->{mv_todo} ='search';
>        $CGI->{mv_nextpage} = 'resultsnews';
>        $CGI->{mv_search_file} = 'News';
>        $CGI->{mv_searchtype} = 'db';
>        $CGI->{mv_coordinate} = 'yes';
>        $CGI->{mv_return_fields} = 'code';
>        $CGI->{mv_matchlimit} = '10';
>        $CGI->{mv_sort_field} = 'category';
>        $CGI->{mv_sort_option} = 'f,n';
>        $CGI->{mv_search_field} = 'category';
>        $CGI->{mv_searchspec} = "$category";
>        $CGI->{banner_text} = "$category";
>        $Tag->update('process');
>        return 1;
> }
> EOR
>

Thanks for responses.

I have managed to now bring in search results successfully (YeeHa!) using 
the following in the resultsnews.html file:

-------------

[search-region]
[search-list]

Category: [item-data News category]<br>
[item-data News newscontent]<br>

<hr>

[/search-list]
[/search-region]

-------------

Which is a sweet break through for me understanding Interchange ActionMaps!
Instead of URLs like:
http://www.domain.com/storename/scan/sp=resultsnews/fi=News/st=db/co=yes/sf=category/se=Hammers/op=eq/rf=code/etc_etc

we are now successfully using:
www.domain.com/storename/news/Hammers
(which I am sure Google will prefer and also much easier to email etc)


Now...the new problem I am hoping for some help with...

I am trying to add some code to our products flypage to generate an 
ActionMap type link to 'news' relating to the flypage items product 
'category'.

[page news/[item-field category]]Latest news for this product 
category[/page]

This works perfectly if the 'category' is a single word (i.e. Hammer) 
generating a link that looks like:
http://www.domain.com/storename/news/Hammers.html?id=YLX8cRV2&mv_pc=19553

however if the category is two or more words (i.e. Hand Tools) the generated 
link looks like this:
http://www.domain.com/storename/news/Hand.html?id=YLX8cRV2&mv_arg=Tools&mv_pc=19358

How do I instead generate a link so that it looks more appropriately like:
http://www.domain.com/storename/news/Hand%20Tools.html?id=YLX8cRV2&mv_pc=19692

Any help greatly appreciated!




More information about the interchange-users mailing list