Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#97 2012-10-24 23:15:26

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

Re: smd_wrap: conditionally wrap stuff with tags and labels

Thanks for the links, Julían! Much appreciated.
On regular-expressions.info and some more regex resources I found the quantifier {2,} as the usual expression for 2 and more. Though, no matter what I use {2,}, {2,20} or {2,}? or even an apparently invented {2-20}, the errors reappear: this time No ending delimiter '#' . I’m pretty much at my wit’s end (in case I ever had some ;)


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

Offline

#98 2012-10-24 23:19:15

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

Re: smd_wrap: conditionally wrap stuff with tags and labels

Could you post the modified code? :)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#99 2012-10-24 23:21:44

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

Re: smd_wrap: conditionally wrap stuff with tags and labels

Sorry that I have to post only to be capable of thinking again: the error said it already, had to use a delim explicitly. D’oh!

After 1 am here, and still working, what should I expect.

Works now, thanks again, Julían!

Last edited by uli (2012-10-24 23:23:46)


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

Offline

#100 2013-12-12 18:57:01

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

Re: smd_wrap: conditionally wrap stuff with tags and labels

When using smd_wrap to format a date, it is defaulting to the timezone where my server is located instead of using the timezone that is set in my TXP installation preferences.

<txp:smd_wrap delim="@" transform="date|%B %e, %l:%M%P %Z"><txp:variable name="starttime" /></txp:smd_wrap>

The variable starttime = 2013-12-19T18:00:00-06:00

The above code outputs: December 19, 5:00pm MST However, I thought it would output to: December 19, 6:00pm CST

The server is in Orem, UT (MST), but my TXP installation is set to Chicago (CST).

Is it possible to adjust it to output for the time zone that is specified in TXP? Not sure if I’m just doing something wrong, if it’s a bug, or if I should be using another method to format the date?

Thanks in advance!

Last edited by photonomad (2013-12-12 18:57:39)

Offline

#101 2013-12-12 21:26:20

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

Re: smd_wrap: conditionally wrap stuff with tags and labels

photonomad wrote:

it is defaulting to the timezone where my server is located instead of using the timezone that is set in my TXP installation preferences.

This may well be a bug, depending on your notion of time. Would you mind trying something out for me please. Edit the plugin code, find this segment:

case 'date':
case 'time':
	$nd = (is_numeric($out)) ? $out : strtotime($out);
	if ($nd !== false) {
		$out = strftime($xform[0], $nd);
	}
break;

and replace it with this:

case 'date':
case 'time':
	$nd = (is_numeric($out)) ? $out : safe_strtotime($out);
	if ($nd !== false) {
		$out = safe_strftime($xform[0], $nd);
	}
break;

If that works and returns your local time then I’ll see if I can modify the date and time routine to allow you to pick which one you want to run (probably via another parameter).

Thanks.

Last edited by Bloke (2013-12-12 21:27:41)


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

#102 2013-12-13 00:37:01

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

Re: smd_wrap: conditionally wrap stuff with tags and labels

Thanks for your reply, Bloke. I made the replacement that you suggested above. Unfortunately, it didn’t change the output. Darn. I thought safe_strtotime would’ve done the trick!

Offline

#103 2013-12-13 01:15:07

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

Re: smd_wrap: conditionally wrap stuff with tags and labels

I found a quick fix! Add the following line (with preferred timezone) to the plugin code:

date_default_timezone_set('America/Chicago');

I put it at the top, just after the start of the function:

function smd_wrap($atts, $thing=NULL) {
        date_default_timezone_set('America/Chicago');

Reference: http://www.php.net/manual/en/function.date-default-timezone-set.php

Last edited by photonomad (2013-12-13 01:47:50)

Offline

#104 2014-02-15 10:55:29

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_wrap: conditionally wrap stuff with tags and labels

Stef, or anyone…

I’m using this variable to create figures/figcaptions. I’d like to use textile in the image caption, but I’m not sure where I’d add the transform wrapper, or if it can even been done in this case.

My guess would have been around the image_info tag as variable, value='<txp:image_info type="caption" />', but that didn’t work. (That’s just showing the location, not inclusion of the wrapper.)

Other possibility?

Offline

#105 2014-02-15 16:35:37

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: smd_wrap: conditionally wrap stuff with tags and labels

Hi, Destry, Try this

<txp:smd_wrap wraptag="figcaption" attr="itemprop|caption" transform="textile">
    <txp:image_info type='caption' />
</txp:smd_wrap>

Offline

#106 2014-02-15 17:20:56

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_wrap: conditionally wrap stuff with tags and labels

Haha. Right, wrap the figcaption, Duh.

Unfortunately it didn’t work. Nether did this, which was easier for me to make sense of…

<txp:smd_wrap transform="textile">
   <figcaption itemprop="caption"><txp:image_info /></figcaption>
</txp:smd_wrap>

It’s not a big deal. I just thought if it could be combined with this variable that would be cool, but oh well.

Offline

#107 2014-02-15 19:03:48

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_wrap: conditionally wrap stuff with tags and labels

Hmm… I think the problem isn’t with rendering Textile, but specifically with rendering Textile links. In a different situation I have this set up…

<txp:if_custom_field name="editor_note">
  <txp:smd_wrap transform="textile" wraptag="aside" class="editornote">
    <b>Note from the editor:</b> <txp:custom_field name="editor_note" />
  </txp:smd_wrap>
</txp:if_custom_field>

I can use basic Textile formatting in the custom field (emphasis, bold…), but if I use a link it doesn’t work. Why not?

Offline

#108 2014-02-15 22:44:59

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: smd_wrap: conditionally wrap stuff with tags and labels

Yes, me too, I forget that custom field, by default Escape html.
One time I’m lose 1 hour with that.

Try

<txp:smd_wrap transform="textile" wraptag="aside" class="editornote">
    <b>Note from the editor:</b> <txp:custom_field name="editor_note" escape="" />
</txp:smd_wrap>

Last edited by sacripant (2014-02-15 22:45:19)

Offline

Board footer

Powered by FluxBB