Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#31 2008-05-28 19:21:24

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Central storage for site-wide constants: Helpful?

That’s exactly what I was thinking of.


Shoving is the answer – pusher robot

Offline

#32 2008-07-02 04:50:36

wet
Developer Emeritus
From: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,416
Website GitHub Mastodon

Re: Central storage for site-wide constants: Helpful?

Offline

#33 2008-07-02 10:06:16

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,475
Website

Re: Central storage for site-wide constants: Helpful?

Brilliant! So many possibilities…


Dozy P My attempt at music

Offline

#34 2008-07-02 10:17:58

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: Central storage for site-wide constants: Helpful?

so is it basically this idea?

Last edited by iblastoff (2008-07-02 10:18:07)

Offline

#35 2008-07-02 10:22:16

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,446
Website GitHub

Re: Central storage for site-wide constants: Helpful?

Yes wet, very useful for those that don’t do stripes in jQuery.

In the same vein… untested but should work if I’ve understood the syntax:

<txp:variable name="plural" value='<txp:comments_count />' />
<p>
  <txp:comments_count /> comment<txp:if_variable name="plural" value="1"/><txp:else />s</txp:if_variable> so far.
</p>

Last edited by Bloke (2008-07-02 10:23:37)


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#36 2008-07-02 10:25:20

wet
Developer Emeritus
From: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,416
Website GitHub Mastodon

Re: Central storage for site-wide constants: Helpful?

iblastoff wrote:

so is it basically this idea?

I think the original base is the Registry Pattern. At least, this is what I had in mind.

Offline

#37 2008-07-02 10:49:30

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: Central storage for site-wide constants: Helpful?

Very sweet little examples for txp_var, Robert and Stef. I’m beginning to see the light ;)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#38 2008-07-02 11:50:06

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: Central storage for site-wide constants: Helpful?

Would this give just todays articles, then?

<txp:variable name="today" value='<txp:php>echo date("Y-m-d");</txp:php>' />
<txp:if_variable name="today" value="<txp:posted format="%Y-%m-%d" />"/>
<txp:output_form form="my_article" />
<txp:else />
No events today!
</txp:if_variable>

In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#39 2008-07-02 11:57:39

wet
Developer Emeritus
From: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,416
Website GitHub Mastodon

Re: Central storage for site-wide constants: Helpful?

At first glance, this is almost working. if_variable receives a Textpattern tag as the attribute’s value, so you would need to enforce parsing with single quotes around <txp:posted format="%Y-%m-%d" />.

<txp:variable name="today" value='<txp:php>echo date("Y-m-d");</txp:php>' />
<txp:if_variable name="today" value='<txp:posted format="%Y-%m-%d" />' />
<txp:output_form form="my_article" />
<txp:else />
No events today!
</txp:if_variable>

Offline

#40 2008-07-02 14:42:59

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

Re: Central storage for site-wide constants: Helpful?

uli wrote:

… I’m beginning to see the light ;)

Well now I can see the light fully. It’s strange but as soon as I read wet’s odd/even example my brain switched to “php mode” and all became clear in a second. Very strange, previously I had an hard time understanding… probably it’s me being completely brain-dead.
Anyway – as ever – thanks, very appreciated

Offline

#41 2008-07-02 16:26:50

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Central storage for site-wide constants: Helpful?

OK, here’s an idea…

For an upcoming project, I’ve decided to adapt this geographic selector to instead show a map of a facility and the various events that are going on at present, and immediately following.

The current region selector is based on articles that have a regional multi-select custom field (thanks to gerhard lazu). Then articles for a region are listed inside a dd and shown with a hover over the associated “visual” dt. Right now I’m using multiple article_custom calls that make each region’s dd.

The new idea would have to use custom fields for day, time and room. Then list events in a room’s dd based on a comparison between “now” == “day+time”.

It all seems theoretically possible, but the specifics are eluding me, and my cranium is minuscule in comparison with those of you gents…

Last edited by mrdale (2008-07-02 16:32:11)

Offline

#42 2008-07-02 18:03:50

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: Central storage for site-wide constants: Helpful?

mrdale wrote:

Then list events in a room’s dd based on a comparison between “now” == “day+time”.

Should be doable for smd_query, I think.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#43 2008-07-02 20:33:27

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Central storage for site-wide constants: Helpful?

Oh yeah, that makes sense. Just need to put together a query…

Offline

#44 2008-07-02 20:43:07

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

Re: Central storage for site-wide constants: Helpful?

I think I’m getting it (but not quite sure yet…). Would this work (in an – individual – article form)?

<txp:if_individual_article>

<h3>Related Articles</h3>

<txp:variable name="match" value='<txp:category1 />' />

<txp:article_custom limit="5">
	<txp:if_article_category name='<txp:variable name="match" />'>
		<txp:if_first_article><ul></txp:if_first_article>
		<li><txp:permlink><txp:title /></txp:permlink></li>
		<txp:if_last_article></ul></txp:if_last_article>
	<txp:else />
		<p>No related articles.</p>
	</txp:if_article_category>
</txp:article_custom>

</txp:if_individual_article>

Offline

#45 2008-07-02 20:46:29

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,446
Website GitHub

Re: Central storage for site-wide constants: Helpful?

mrdale

Is this still related to your foreach thing? I couldn’t quite get my head round your problem. If I get a chance I’ll take another gander.


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB