SOLVED CGBlog thumbnails and categories in Search results

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
WeeJimmyHat
Forum Members
Forum Members
Posts: 18
Joined: Fri Feb 18, 2011 10:17 pm

SOLVED CGBlog thumbnails and categories in Search results

Post by WeeJimmyHat »

I have a site keyword search which only searches CGBlog module entries.

I'd like each item on the search results page to have a title, thumbnail image and which CGBlog category(s) the entry was posted in.

So far I can only make the title show up. The link to the blog entry is also working.

Code: Select all

<div class="grid">
<h3>{$entry->category.name}</h3>
<h2><a href="{$entry->url}">{$entry->urltxt}</a></h2>

<a href="{$entry->url}"><img src="{$entry->file_location}/{$entry->fieldsbyname.Thumbnail->value}" width="300" height="142" /></a>

</div>
I'm running CMSMS 1.11.8, CGBlog 1.10.3, Search 1.7.10

Anyone got any ideas? Any help greatly appreciated - I've been searching the forums and trying various code combinations for ages with no success.
Last edited by WeeJimmyHat on Sun Sep 29, 2013 8:43 pm, edited 1 time in total.
WeeJimmyHat
Forum Members
Forum Members
Posts: 18
Joined: Fri Feb 18, 2011 10:17 pm

Re: Display CGBlog thumbnails and categories in Search resul

Post by WeeJimmyHat »

OK, I got the thumbnails and categories displaying, but I can't get the title or thumbnail to link to the CGBlog entry details page.

Here's my code for the Search Result Template:

Code: Select all

{if $itemcount > 0}
{foreach from=$results item=entry}

{if $entry->module == "CGBlog"}

<div class="grid">
{cms_module module="CGBlog" action="detail" articleid=$entry->modulerecord      
       detailtemplate="selectedfields"}
</div>

{/if}
{/foreach}

{else}
<h2>{$noresultsfound}</h2>
{/if}
And here's the CGBlog Detail View Template 'selectedfields':

Code: Select all

{if $entry->categories}
{strip}
<h3>{foreach from=$entry->categories item='category'}
{$category.name}&nbsp;
{/foreach}</h3>
{/strip}
{/if}

<h2><a href="{$entry->url}">{$entry->title|escape}</a></h2>

<a href="{$entry->detail_url}"><img src="{$entry->file_location}/{$entry->fieldsbyname.Thumbnail->value}" width="300" height="142" /></a>
As you can see I've tried using {$entry->url} and {$entry->detail_url} to link through to the details page, but neither works - the H2 and image links come out empty <a href="">....</a>

Any ideas out there?
WeeJimmyHat
Forum Members
Forum Members
Posts: 18
Joined: Fri Feb 18, 2011 10:17 pm

Re: Display CGBlog thumbnails and categories in Search resul

Post by WeeJimmyHat »

Yeeeees! Done it.

/details is the name set in the CGBlog > Options 'Prefix to use on all URLS from the blog module' field.

{$entry->id} returns the obvious, and the cms_escape:htmlall bit forces the entry title to become a url

Maybe a tad clunky but it works perfectly :)

Code: Select all

{if $entry->categories}
{strip}
<h3>{foreach from=$entry->categories item='category'}
{$category.name}&nbsp;
{/foreach}</h3>
{/strip}
{/if}

<h2><a href="/details/{$entry->id}/{$entry->title|cms_escape:htmlall}">{$entry->title|escape}</a></h2>

<a href="/details/{$entry->id}/{$entry->title|cms_escape:htmlall}"><img src="{$entry->file_location}/{$entry->fieldsbyname.Thumbnail->value}" width="300" height="142" /></a>
Post Reply

Return to “Modules/Add-Ons”