Features / Usability

Features / Usability

Adding page description to tiki-listpages

posts: 3661 United States

In the list of wiki pages (tiki-listpages) I want to add a description (basically the first 150 words on the page) directly under the name of the page.

I thought that simply adding:

<br />

would work. But it doesn't make any change in the page at all. Can anyone help? question


posts: 32 United States
{$listpages[changes].description|truncate:150:"...":true} rather
posts: 3661 United States

Yeah, but that pulls only from the description field in the table. I actually want to grab the first 150 characters on the page. For example, when you use the Search, you get a portion of the actual page — that's what I want.



posts: 1092

I didn't try but that should be ok

posts: 3661 United States

Nope. Nada. Nil.

My code in tiki-listpages.tpl looks like this:
< td class="{cycle advance=false}"> < a href="tiki-index.php?page={$listpages[changes].pageName|escape:"url"}" class="tableheading" title="{$listpages[changes].pageName}">{$listpages[changes].pageName} < br /> {$listpages[changes].data|truncate:125:"...":true} < /td>

You can see the page in action at:

posts: 32 United States

That would either be




Both have problems.

The 'data' version is unparsed; i.e., it will not convert a to the start of the table of contents, etc. You could add a line to parse the page in the php file and then return the first 150 characters of that, but that would be horrifically slow (you could also parse just the first 150 characters, but that may result in errors, such as if you get only part of a wiki-plugin).

The 'cache' version is parsed, but...
1) it may not exist
2) limiting the number of characters will likely result in malformed HTML. You could translate the &lt; and &gt; to &amp;lt; and &amp;gt;, but again, that would be slow.

posts: 1092

THis time , I do some testing - sorry.
the description is not return from the database.
So if you are working with 1.9 cvs. I just did the change. So update.
Otherwise you have to change lib/tikilib.php , function list_pages

$query = "select `creator` ,`pageName`, `hits`, `page_size` as `len`, `lastModif`, `user`, `ip`, `comment`, `version`, `flag` ";
	$query = "select `creator` ,`pageName`, `hits`, `page_size` as `len`, `lastModif`, `user`, `ip`, `comment`, `version`, `flag` , `description`";

and before
	$ret[] = $aux;
you have to add
	$aux["description"] = $res["description"];


Upcoming Events

No records to display