Simple tag cloud using Search and News

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Locked
Simon66
Power Poster
Power Poster
Posts: 250
Joined: Wed Aug 29, 2007 4:36 am
Location: Sydney Australia

Simple tag cloud using Search and News

Post by Simon66 »

In News settings I created a text field called Comma_Separated_Tags.

In Design Manager I create a Search Form Template:

Code: Select all

{$startform}
<input class="button button-3d button-mini button-rounded" id="{$search_actionid}searchinput" name="{$search_actionid}searchinput" value="holder" type="submit" />
{if isset($hidden)}{$hidden}{/if}
{$endform}
This uses just the form button to pass a value of "holder" to the search.

Next, in the News Detail Template, I added this code:

Code: Select all

{$cloudwords = ","|explode:$entry->fieldsbyname.Comma_Separated_Tags->value}
            {foreach from=$cloudwords item=words}
            {Search|replace:"holder":$words search_method="post"} 
            {/foreach}
This loops through the array and creates a separate form (each with a unique ID) for each search word/phrase and replaces "holder" with those words from the array.

Then a bit of CSS to make the forms play nice with each other:

Code: Select all

.cms_form { display: inline-block; }
Now each News Article has a Tag Cloud where each word will do a global search for related content.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Simple tag cloud using Search and News

Post by calguy1000 »

This should do the trick too: Rather than a special form template, and umpteen forms, you just need links.

Code: Select all

<a href="{cms_action_url module=Search action=dosearch searchinput=$word}">{$word}</a>
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Simon66
Power Poster
Power Poster
Posts: 250
Joined: Wed Aug 29, 2007 4:36 am
Location: Sydney Australia

Re: Simple tag cloud using Search and News

Post by Simon66 »

Thanks CalGuy I'll try that.
jakubr
New Member
New Member
Posts: 3
Joined: Wed Nov 13, 2019 10:58 am

Re: Simple tag cloud using Search and News

Post by jakubr »

I've tried original @Simon66 and also modified @calguy1000 solutions. List of "buttons" with tags or just links works perfectly, but there is a weird problem with search results - links in results points to some nonexistent page in admin panel, for example:

Code: Select all

https://mysite.com/admin/index.php?mact=News,cntnt01,detail,0&cntnt01articleid=1&cntnt01returnid=0
Don't know what is the cause of this problem. I've tested ordinary search form (input field + button), and it gives results with correct links.
Locked

Return to “Tips and Tricks”