Jump to content

Conditional for $category->_description not evaluating


Meddysong

Recommended Posts

I'm a bit stumped on this.

Here's a category in one of my Pages databases:

Untitled-1.thumb.jpg.c7acd1619f5953ae09ec1e5726f66e68.jpg

The category header and description are called by the following in the categoryHeader template:

<div class="articles__banner">
	<p class="articles__title"><span>{$category->_title}</span></p>
	{{if $category->_description}}<p class="articles__description"><span>{$category->_description}</span></p>{{endif}}
</div>

My categories which don't have descriptions should show only the title, since the conditional check on descriptions should evaluate to FALSE. That's not what's happening, however:

Untitled-1.thumb.jpg.7adcb7504c0824db5b5b8a59729f2936.jpg

My source is showing:

<div class="articles__banner">
	<p class="articles__title"><span>Creative Writing</span></p>
	<p class="articles__description"><span></span></p>
</div>

In other words, the conditional statement is evaluating to TRUE. You can see, however, that {$category->_description} isn't producing any output.

I amended my statement slightly to:

{{if !empty($category->_description)}}<p class="articles__description"><span>{$category->_description}</span></p>{{endif}}

Still the same result.

I thought I'd add {$category->_description} without any statement in the body. Since I knew there wasn't any content and it would therefore be invisible, I added a little marker:

<div class="articles__banner">
	<p class="articles__title"><span>{$category->_title}</span></p>
	{{if !empty($category->_description)}}<p class="articles__description"><span>{$category->_description}</span></p>{{endif}}
</div>
<p>{$category->_description}-xx</p>

And it once again produced nothing:

Untitled-1.thumb.jpg.2a963bbeca1b82f6a5cc2d6fa244c1b7.jpg

This doesn't make any sense to me. Am I missing anything?

Link to comment
Share on other sites

$category->_description return Unique id

\system\Lang\Lang.php

	/**
	 * Add to output stack
	 *
	 * @param	string	$key	Language key
	 * @param	bool	$vle	Add VLE tags?
	 * @param	array	$options Options
	 * @return	string	Unique id
	 */
	public function addToStack( $key, $vle=TRUE, $options=array() )

You can use

{{$description = $category->_description;}}
{{\IPS\Member::loggedIn()->language()->parseOutputForDisplay($description);}}
{{if $description}}<p class="articles__description"><span>{$description}</span></p>{{endif}}
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...