StaticPages Validation Error

Found a bug? Tell us!!
Post Reply
DB
Regular
Posts: 22
Joined: Mon May 01, 2006 9:40 pm
Contact:

StaticPages Validation Error

Post by DB »

Hello,

It was brought to my attention that when performing "Quicksearch" an HTML validation error would be generated if 0 static pages existed, and the static pages plugin was installed.

Quick Fix:

In the "plugin_staticpage_searchresults.tpl" file, change the following:

Code: Select all

<ul class="staticpage_result">
{foreach from=$staticpage_results item="result"}
        <li><strong><a href="{$result.permalink|@escape}" title="{$result.pagetitle|@escape}">{$result.headline}</a></strong> ({$result.realname})<br />
        {$result.content|@escape:htmlall|@truncate:200:" ... "}</li>
 {/foreach}
</ul>



to

Code: Select all

{foreach from=$staticpage_results item="result"}
<ul class="staticpage_result">
        <li><strong><a href="{$result.permalink|@escape}" title="{$result.pagetitle|@escape}">{$result.headline}</a></strong> ({$result.realname})<br />
        {$result.content|@escape:htmlall|@truncate:200:" ... "}</li>
</ul>
    {/foreach}
Basically, you just want your Smarty to pull up the "ul class" only if there is something to display. If there is nothing to display (no "li"), a validation error is produced because it is assumed that a "li" should live within a "ul".

Fun stuff, and thank you to Frank

DB
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

The problem with this is that you're opening and closing the unordered list for each and every item. This isn't a very pretty solution, however a simple {if} statement around the original entire static pages results would definitely work for your purpose. Try editing plugin_staticpage_searchresults.tpl to look like the following;

Code: Select all

{if $staticpage_results}
<div class="staticpage_results" style="text-align: left">
    <p class="staticpage_result_header"> {$CONST.STATICPAGE_SEARCHRESULTS|sprintf:$staticpage_searchresults}</p>

    <ul class="staticpage_result">
    {foreach from=$staticpage_results item="result"}
        <li><strong><a href="{$result.permalink|@escape}" title="{$result.pagetitle|@escape}">{$result.headline}</a></strong> ({$result.realname})<br />
        {$result.content|@escape:htmlall|@truncate:200:" ... "}</li>
    {/foreach}
    </ul>
</div>
{/if}
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Good finding! I committed carls solution!

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply