Page 1 of 1

StaticPages Validation Error

Posted: Mon Dec 11, 2006 2:25 am
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

Posted: Mon Dec 11, 2006 5:54 am
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}

Posted: Mon Dec 11, 2006 11:39 am
by garvinhicking
Hi!

Good finding! I committed carls solution!

Regards,
Garvin