Forums / Setup & design / If-then-else and is_empty

If-then-else and is_empty

Author Message

Trond Hjelmaas

Thursday 28 April 2005 12:16:33 am

Hi,

I have two sorts of articles in one "News" folder. I take the 4 most recent and put their title (or name) at the frontpage(and a "Read more" link) .

The problem is that article type 1 has a title and article type 2 has no title but a name (yes, it does make sense :) ).

So my problem is that when I use "is_empty" on a title it works fine, however, when there is no title (only a name) I don't get the {section-else} printed.
Look at this code:

{section show=$:item.object.data_map.title.content.is_empty|not}
 {attribute_view_gui attribute=$:item.object.data_map.title};
{section-else}
 {attribute_view_gui attribute=$:item.object.data_map.name};
{/section}

The "is_empty" part is my problem. I cannot test if the title is empty (or full) when an article has a name only...

Can I switch the "is_empty" with "does_exists" or something like that? Any other suggestions are very welcome :)

Thanks in advance!

Trond H

Eivind Marienborg

Thursday 28 April 2005 12:19:19 am

Maybe is_valid could work?

Trond Hjelmaas

Thursday 28 April 2005 12:29:12 am

Thanks for suggestion, I tried:
{section show=$:item.object.data_map.title.is_valid}

and
{section show=$:item.object.data_map.title.content.is_valid}

but it goes to {section-else} 100% of the time.

Any other suggestions :) ?

Eivind Marienborg

Thursday 28 April 2005 12:38:58 am

How about setting up the title as name pattern for the article that has a title? Then you could print

$:item.name

on both classes.

Trond Hjelmaas

Thursday 28 April 2005 12:41:54 am

That sounds like a great idea!, but I don't know how to create a "name pattern". Would you have any more information?

Thanks again :)

Eivind Marienborg

Thursday 28 April 2005 12:47:46 am

Edit your class, you'll probably see it right away, right at the top, along with class name and identifier :)

Trond Hjelmaas

Thursday 28 April 2005 1:55:00 am

Hi, found the name pattern. I also search for help using this attribute, not much luck with examples.

I currently have article class (default) with
Object name pattern: <short_title|title>

Do you have any suggestion how I add "name" in here? My intuition says something like <short_title|title|name=title>...

Would you have a link to documentation regarding "object name pattern" and/or "is_empty/is_valid" attributes?

Thanks

Thanks and thanks

Eivind Marienborg

Thursday 28 April 2005 2:03:53 am

The $:item.name is set by the object name pattern. So if you set your name pattern to <title>, accessing $:item.name will output the same as $:item.object.data_map.title.

Regarding is_valid/is_empty, I'd recommend a search through the docs/forum here on ez.no, and a grep through the standard templates for examples.

Tore Skobba

Thursday 28 April 2005 4:00:14 am

Hi

Try to use the "has_content" instead (http://www.ez.no/ez_publish/download/changelogs/ez_publish_3_4/datatype_changes )

Norman Leutner

Wednesday 08 June 2005 7:14:31 am

That doesn't seem to be the best way..
If you edit the object any remove attribute,
.has_content still keeps true.

--> has_content boolean true

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

Marko Žmak

Wednesday 08 June 2005 10:35:01 am

You could also try:

is_set($:item.object.data_map.title)

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

eZ debug

Timing: Jan 31 2025 04:26:46
Script start
Timing: Jan 31 2025 04:26:46
Module start 'content'
Timing: Jan 31 2025 04:26:46
Module end 'content'
Timing: Jan 31 2025 04:26:46
Script end

Main resources:

Total runtime0.1233 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 587.9297180.8359
Module start 'content' 0.00740.0058 768.7656105.9922
Module end 'content' 0.01320.1101 874.7578535.0234
Script end 0.1232  1,409.7813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00342.7182200.0002
Check MTime0.00131.0631200.0001
Mysql Total
Database connection0.00100.846710.0010
Mysqli_queries0.081566.12831410.0006
Looping result0.00100.79041390.0000
Template Total0.109789.010.1097
Template load0.00090.730910.0009
Template processing0.108888.223610.1088
Override
Cache load0.00060.512410.0006
Sytem overhead
Fetch class attribute can translate value0.00080.649710.0008
XML
Image XML parsing0.00030.236910.0003
General
dbfile0.00614.9823200.0003
String conversion0.00000.004830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs