Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#265 2009-11-19 20:09:44

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Re: smd_if: Generic multiple if condition tests

I use txp:output_form to reference the main menu from every page template in my site. I was just working on the error_default page and realized that the menu code below wasn’t displaying section links like it does everywhere else in the site:

<txp:section name="nameofsection" link="1" title="1" wraptag="h2" <txp:smd_if field="section,parent" operator="eq,contains" value="nameofsection,nameofsection" logic="or">class="selected"</txp:smd_if> />
<txp:section name="anothernameofsection" link="1" title="1" wraptag="h2" <txp:smd_if field="section,parent" operator="eq,contains" value="anothernameofsection,anothernameofsection" logic="or">class="selected"</txp:smd_if> />

I ended up having to place the menu code directly in the error_default page and remove the smd_if part from each txp:section tag to get it to work. I just thought it was kind of strange that smd_if would break the txp:section tag only on error_pages and thought I’d mention it here.

Offline

#266 2009-11-25 07:26:36

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: smd_if: Generic multiple if condition tests

speeke wrote:

<txp:smd_if field=“urlvar:countries” operator=“in” value=”[results of query here, separated by a slash]”>

Could you use smd_query and tags within tags?


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#267 2009-11-25 21:10:57

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: smd_if: Generic multiple if condition tests

not tested but this should work if I’m reading the plugin instructions correctly. I did test the smd_query part with a slightly different query.

<txp:variable name="fieldValues" value='<txp:smd_query query="SELECT DISTINCT custom_13 FROM textpattern WHERE section = 'section_name' AND status = 4 GROUP BY custom_13">{custom_13}/</txp:smd_query>'/>

Last edited by MattD (2009-11-25 21:11:34)


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#268 2009-11-25 22:34:51

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: smd_if: Generic multiple if condition tests

If you try it with just the smd_if you should see the output on the page. I tried it with this query to confirm it returned the results I expected.

<txp:smd_query query="SELECT DISTINCT custom_1 FROM textpattern WHERE status = 4 and custom_1 is not null and custom_1 != '' GROUP BY custom_1">{custom_1}/</txp:smd_query>

Giving me the following results which is a list of longitudes i have in the custom_1 field.

34.61399647590717/36.456207/36.6097641273077/36.618253/36.63329984895536/36.6439807/36.65953737334756/36.661120979806085/36.68050030625411/36.680561/36.69072153677273/36.69099683732502/37.77833010785869/

The only issue I see is removing the last delimiter.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#269 2009-11-26 05:17:36

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: smd_if: Generic multiple if condition tests

You’re right. When using smd_query inside txp:variable I get an error.

Tag error: <txp:smd_query query="SELECT DISTINCT custom_1 FROM textpattern WHERE status = 4 and custom_1 is not null and custom_1 != ' GROUP BY custom_1"> ->  Textpattern Warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' GROUP BY custom_1' at line 1
SELECT DISTINCT custom_1 FROM textpattern WHERE status = 4 and custom_1 is not null and custom_1 != ' GROUP BY custom_1
textpattern/lib/txplib_misc.php(594) : eval()'d code:69 getRows()  on line 85
textpattern/lib/txplib_db.php:85 trigger_error()
textpattern/lib/txplib_db.php:272 safe_query()
textpattern/lib/txplib_misc.php(594) : eval()'d code:69 getRows()
textpattern/publish.php:1146 smd_query()
textpattern/publish.php:1081 processTags()
textpattern/lib/txplib_misc.php:977 parse()
textpattern/publish.php:1146 splat()
textpattern/publish.php:1068 processTags()
textpattern/publish.php:506 parse()
index.php:45 textpattern()

My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#270 2009-11-26 08:20:37

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

Re: smd_if: Generic multiple if condition tests

MattD wrote:

You’re right. When using smd_query inside txp:variable I get an error.

That’s ‘cos of the double single quote '' in the query ending the variable definition.

EDIT: Ignore my stupid smd_each ramblings; didn’t read the problem properly. How about this using the smd_query break attribute to fix the trailing slash problem and using txp:variable as a container to bypass all the quoting issues:

<txp:variable name="fieldValues"><txp:smd_query query="SELECT DISTINCT custom_13 FROM textpattern WHERE status = 4 and custom_13 is not null and custom_13 != '' GROUP BY custom_13" break="/">{custom_13}</txp:smd_query></txp:variable>

Any good if you plug ?fieldValues into your smd_if?

Last edited by Bloke (2009-11-26 08:29:24)


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

#271 2009-11-26 08:38:09

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: smd_if: Generic multiple if condition tests

Ah, and I had tested it earlier without the !='' which is why I expected it to work.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#272 2010-02-02 19:05:01

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

Re: smd_if: Generic multiple if condition tests

Hey!
I will like to know how to do the next thing:
I got two sections “a” and “b”,
and I want to display a custom articles list of section “b” that have the same posted date as the articles of section “a”.

so will it be something like this?:

<txp:article_custom section="a" limit="999">
<txp:smd_if field="section, posted" value="b, <txp:posted format='%Y-%m-%d' />">
<txp:article_custom section="b" limit="999" month='<txp:posted format="%Y-%m-%d" />'>
<txp:permlink><txp:title /></txp:permlink><br />
</txp:article_custom>
</txp:smd_if>
</txp:article_custom>

Offline

#273 2010-02-03 20:54:43

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

Re: smd_if: Generic multiple if condition tests

Any idea what do I need to put into the ‘field’ attribute?
the ‘posted’ is not working, and do I need to add any ‘operator’ attribute please?

Offline

#274 2010-02-03 22:25:20

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

Re: smd_if: Generic multiple if condition tests

THE BLUE DRAGON wrote:

the ‘posted’ is not working,

Does it work if you change

value="b, <txp:posted format='%Y-%m-%d' />"

to

value='b, <txp:posted format="%Y-%m-%d" />'

Offline

#275 2010-02-03 22:29:37

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

Re: smd_if: Generic multiple if condition tests

no it’s not :(

Offline

#276 2010-02-03 22:38:19

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

Re: smd_if: Generic multiple if condition tests

No, I didn’t expect it to work ;) I don’t quite understand what you are trying to do. Are you refering to an individual article page, displaying one article in section a, and you want a list of articles in section b with the same posted date? If so, I don’t think you need the plugin.

Offline

Board footer

Powered by FluxBB