Magic Data • expression within an expression
Permalink Browser Info Environment
I'm utilizing the Magic Data Page List teasers template, and using Magic Data purely as an "extension" of HTML to lay out the main area of the pages and manipulate the "teaser" view on the main list page (130 in the example below).
Is it possible to place an expression within an expression like in my example, in an effort to avoid testing the CID over and over for multiple pieces of HTML? Currently this will spit out the "orig page, display att, href" symbols in the display html without processing them. Ref firefox web dev.
Is it possible to place an expression within an expression like in my example, in an effort to avoid testing the CID over and over for multiple pieces of HTML? Currently this will spit out the "orig page, display att, href" symbols in the display html without processing them. Ref firefox web dev.
[%CID EQ 130 IF ( 'Text, Javascript, HTML, or Magic Data expression' ) ( '<div class="blog-image-teaser"><img src="( ORIGINAL_PAGE DISPLAY_ATTRIBUTE blog_image HREF )" style="max-width: 30%;"></a></div>' ) %] [%CID EQ 130 IF ( ' ' ) ( '</div>' )%]
Type: | Discussion |
---|---|
Status: | Archived |
My objective here was:
CID 130 is the "blog list" page. On this page I'm using Page List Plus (Skybluesofa) with a copy of the "Page List" Magic Data Teasers template to display what I'm hashing out as HTML/MD in the "main" areas on each blog post page.
What I was specifically looking for was the simplest way to get expressions within expressions to render properly with the least amount of code or additional MD symbols. Example #1 definately fits the bill and works like a charm!
The additional /div was my mistake and has been corrected. Example of working HTML/MD code for future reference is as follows:
CID 130 is the "blog list" page. On this page I'm using Page List Plus (Skybluesofa) with a copy of the "Page List" Magic Data Teasers template to display what I'm hashing out as HTML/MD in the "main" areas on each blog post page.
What I was specifically looking for was the simplest way to get expressions within expressions to render properly with the least amount of code or additional MD symbols. Example #1 definately fits the bill and works like a charm!
The additional /div was my mistake and has been corrected. Example of working HTML/MD code for future reference is as follows:
[%CID EQ 130 IF ( 'Text, Javascript, HTML, or Magic Data expression' ) ( '<div class="blog-image-teaser"><img src="' . ( ORIGINAL_PAGE DISPLAY_ATTRIBUTE blog_image HREF ) . '" style="max-width: 30%;"></a>' ) %] [%CID EQ 130 IF ( ' ' ) ( '</div>' )%]
For others who use Magic Data and/or Page List Plus, I have submitted a How-To outlining how to use the Magic Data Page List Teasers template as described above.
I will share a link here upon How-To approval.
I will share a link here upon How-To approval.
The how-to is now available here:
http://www.concrete5.org/documentation/how-tos/designers/magic-data...
http://www.concrete5.org/documentation/how-tos/designers/magic-data...
The expression below will show the image generated by MD for CID == 130. Like php, one type of quote within another type of quote is ignored.
Another way of structuring it would be to use WRAP to place the html code about the inner expression.
Much of the parenthesis here is not really needed, so it could equally be:
Another approach is with FORMAT:
If what you are really aiming for is two levels of evaluation, you could also look at the RAW symbol in Magic Data Developer.