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.

[%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: New
enlil
View Replies: View Best Answer
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
I am not clear what you are aiming for here. What you have in the example will, I suspect, lead to one too many </div> tags.

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.

[%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>' )
%]


Another way of structuring it would be to use WRAP to place the html code about the inner expression.

CID EQ 130 IF
( 'Text, Javascript, HTML, or Magic Data expression' )
( ORIGINAL_PAGE DISPLAY_ATTRIBUTE blog_image HREF  
WRAP ( '<div class="blog-image-teaser"><img src="' ) (  '" style="max-width: 30%;"></a></div>'  ) )


Much of the parenthesis here is not really needed, so it could equally be:
CID EQ 1 IF
( 'Text, Javascript, HTML, or Magic Data expression' )
( ORIGINAL_PAGE DISPLAY_ATTRIBUTE blog_image HREF  
WRAP '<div class="blog-image-teaser"><img src="'  '" style="max-width: 30%;"></a></div>'  )


Another approach is with FORMAT:
CID EQ 130 IF
( 'Text, Javascript, HTML, or Magic Data expression' )
( ORIGINAL_PAGE DISPLAY_ATTRIBUTE blog_image HREF SAVE 'm1' 
'<div class="blog-image-teaser"><img src="{{m1}}" style="max-width: 30%;"></a></div>'  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.
enlil replied on at Permalink Reply
enlil
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 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>' )%]
enlil replied on at Permalink Reply
enlil
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.
enlil replied on at Permalink Reply
enlil

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.