Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#49 2008-11-05 01:07:43

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: an attribute named "empty"

Surely I’m wrong but can’t it depend upon how you have nested double quotes in your <txp:variable />?

this:

<txp:variable name="file_count" value='<txp:file_download_list form="file_cat" category="<txp:l10n_get_lang type="short" />" />' />

shouldn’t be this?:

<txp:variable name="file_count" value='<txp:file_download_list form="file_cat" category="<txp:l10n_get_lang type='short' />" />' />

Note the single quotes around the attribute “short”

edit: Oops, Bloke was faster and more precise

Last edited by redbot (2008-11-05 01:09:26)

Offline

#50 2008-11-05 01:12:40

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: an attribute named "empty"

Phew… am I glad that it’s not just me… ;)

Your findings are exactly like mine. I started with single quotes around the third nested tag, and later on changed it to double quotes. Because the output of the variable tag is correct, I didn’t think that the multi-level nesting would be the problem… but I’m not sure of course.

Unless there’s another way to rewrite it with only a single level of nesting…?

Oh, I can always find another way to do it. I can put the file download code in the articles, I’ll only have to remember to add it to the pt article whenever I’m going to add files to that category as well.
But I really liked my piece of code ;) and it would have been fully automated that way. Oh well, we can’t have everything I guess… ;) (and there is always chh_if_data)

Thanks very much for confirming my sanity!

Offline

#51 2008-11-05 01:16:07

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: an attribute named "empty"

redbot wrote:

Note the single quotes around the attribute “short”

I even tried it that way, but it doesn’t get parsed right if you do that, in the tag trace it looked like this:

[SQL (0,000139951705933): select *,`l10n_description_en_gb` as `description` from txp_file where 1=1 and category IN ('<txp:l10n_get_lang type=\'short\' />') and status = '4' order by filename asc limit 0, 10]

Offline

#52 2008-11-05 01:20:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: an attribute named "empty"

redbot wrote:

Note the single quotes around the attribute “short”

Yeah, I thought that would be it as well. I’ve tried all these permutations so far and have had not had the “right” answer yet:

<txp:variable name="file_count" value='<txp:file_download_list form="file_cat" category="<txp:l10n_get_lang type="short" />" />' />
<txp:variable name="file_count" value="<txp:file_download_list form="file_cat" category="<txp:l10n_get_lang type="short" />" />" />
<txp:variable name="file_count" value='<txp:file_download_list form="file_cat" category='<txp:l10n_get_lang type="short" />' />' />
<txp:variable name="file_count" value='<txp:file_download_list form="file_cat" category="<txp:l10n_get_lang type='short' />" />' />
<txp:variable name="file_count" value="<txp:file_download_list form="file_cat" category="<txp:l10n_get_lang type='short' />" />" />
<txp:variable name="file_count" value="<txp:file_download_list form="file_cat" category='<txp:l10n_get_lang type="short" />' />" />

I got bored of trying after that lot :-P

Must be some scientific way of proving this or working out the correct single/double quote syntax to render the correct result. I’ve even tried approaching it as if I was the parser, going in as far as I can and successively working out — reverse-Polish stylie — but my brain went soggy.

Last edited by Bloke (2008-11-05 01:21:46)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#53 2008-11-05 01:31:41

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: an attribute named "empty"

Bloke wrote:

I’ve even tried approaching it as if I was the parser, going in as far as I can

Sounds a bit like Being John Malkovich… seriously, don’t go in too deep or you’ll at least have nasty dreams tonight.
Maybe one of the devs can shed some light on this. Tomorrow. Thanks again and sleep well :)

Offline

#54 2008-11-05 12:38:32

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: an attribute named "empty"

<txp:variable name="file_count" value='<txp:file_download_list form="file_cat" category=''<txp:l10n_get_lang type="short" />'' />' />

escaping of quotes in 4.0.7 attribute values is done by using 2 consecutive quotes.

Offline

#55 2008-11-05 12:57:27

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: an attribute named "empty"

ruud wrote:

escaping of quotes in 4.0.7 attribute values is done by using 2 consecutive quotes.

Awesome, it works poifickly!

Thanks for clearing that up. I’d have been there all day figuring that out on my own. Must have missed that bit in your parser write-up doc.

Last edited by Bloke (2008-11-05 12:58:12)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#56 2008-11-05 17:21:46

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: an attribute named "empty"

Perfect! Thanks Ruud! Great that it can be done after all, now anything seems possible… :)

Offline

#57 2008-12-24 14:19:58

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: an attribute named "empty"

Look at this tip on TXP Tips.
I think it’s an interesting (and simple) case for dissection.

For the sake of brevity and clarity, I will rewrite it using container tags instead of forms, and also omitting some chunks of code that aren’t essential for this dissection.

<txp:section_list class="" break=""
wraptag="dl" sections="about,services,case-studies,contact">
  <txp:if_section name='<txp:section />'>
    <txp:article_custom section='<txp:section />' form="nav.build.link" />
  </txp:if_section>
</txp:section_list>

The important part (where at first I thought there was a mistake, but now I think it’s a great example on how this thing works) is this:

  <txp:if_section name='<txp:section />'>
  <txp:article_custom section='<txp:section />' form="nav.build.link" />
  </txp:if_section>

As wet clearly explained, some tags (txp:section, for example) are “tag context sensitive”.
So, the above chunk of code, read in plain simple english:

If section for current URL is equal to section currently iterated (txp:section) on this section list, then output a list of articles for this current iterated section.

Great! :D

BTW: I think that when 4.0.7 was out, there was a bug, and txp:section value wasn’t reverted back to its corresponding value after leaving the iteration. Where’s the patch for that? (can’t find it)

Last edited by maniqui (2008-12-26 20:35:36)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#58 2008-12-26 20:32:05

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: an attribute named "empty"

maniqui

Nice explanation, thanks. It is certainly very cool what’s possible in 4.0.7 now. Not just in terms of new tags, but some severely awesome enhancements “under the hood” that enables stuff like this. And searching arbitrary columns. And time/event-based articles. And…

I think that when 4.0.7 was out, there was a bug, and txp:section value wasn’t reverted back to its corresponding value after leaving the iteration. Where’s the patch for that? (can’t find it)

r3037 ?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#59 2008-12-26 20:40:23

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: an attribute named "empty"

Thanks, Bloke, glad you liked it.

I fixed an error on the “plain english” version, I don’t know why I typed txp:title instead of txp:section.

Thanks for pointing to the fixed version of taghandlers.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB