Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Meddysong Posted October 31, 2018 Posted October 31, 2018 I'm a bit stumped on this. Here's a category in one of my Pages databases: 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: 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: This doesn't make any sense to me. Am I missing anything?
Daniel F Posted October 31, 2018 Posted October 31, 2018 ->_description is always returned, even if it's an empty string, so if( isset()) won't work! You could probably try {{if $category->_description != '' }}
Meddysong Posted October 31, 2018 Author Posted October 31, 2018 Tried it, Daniel. No joy, unfortunately. Is that just a quirk of ->_description or does it apply to other things too?
newbie LAC Posted October 31, 2018 Posted October 31, 2018 $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}}
Recommended Posts
Archived
This topic is now archived and is closed to further replies.