Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: smd_macro: Create custom virtual Txp tags that do stuff
Good lord, I love this thing…
The one thing that is causing my forehead to go flat is the <p> tags issue. I’ve tried the rah_replace option, but can’t seem to get that to work. It seems to be closing the opening <p> of any paragraph I insert a macro in before the macro code, and then inserting an empty <p></p> at the end.
Can anyone verify rah_replace effectively removing the <p> tags?
Love shouldn’t be this frustrating. :)
Last edited by renobird (2011-12-14 20:52:46)
Offline
Re: smd_macro: Create custom virtual Txp tags that do stuff
Hi.
I have a problem with import/export.
I have exported a macro from my localhost website and I try to import it into my publish website but i get this text:
Macro file not in expected format
What is the problem?
Offline
Re: smd_macro: Create custom virtual Txp tags that do stuff
v0.20 is out which sports:
- (fanfare) Container macros — thanks to jakob for testing
- Fixed UTF-8 collation and character set issues — thanks Uli / jakob
- Forced lower case attribute names — thanks Uli
- Fixed hyphen/underscore bug and sanitized tag attributes — thanks Uli
Hope the new container support allows you to do much more with your macros and virtual tags. The offer still stands if anybody comes up with some cool tags that might be useful to others, I’ll put them in the plugin help.
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
Online
Re: smd_macro: Create custom virtual Txp tags that do stuff
Macro file not in expected format
Marco, not sure if you still have the problem, but this happened to me today until I replaced /tmp
with the whole path to the temp dir from root in the advanced prefs.
TXP Builders – finely-crafted code, design and txp
Offline
Re: smd_macro: Create custom virtual Txp tags that do stuff
Hi Stef,
This might interest you (or may not). That link links to one of my plugin’s issue tracker where Jools-r asked if I could add some extending functionality that other plugins, specifically smd_macro, could use. I did, and added hooking points for other plugins.
This secrecy. What is that plugin? Rah_flat, which allows editing “any” database table as flat files with the help of XML configuration files. What does that have do with you? Smd_macro. Static files. Those callbacks. Post-submit compiling ;-)
Huh what? Some as in here, or specifically as in case of smd_macro:
register_callback('smd_macro_pancake', 'rah_flat.importing');
function smd_macro_pancake($event='', $step='', $table='') {
if($table != 'smd_macro')
return;
/*
Gets the row currently being imported
*/
$data = rah_flat::row();
/*
Builds attribute, um, somehow, not sure... as JSON? I.e.
<meta>
<attributes>{ 'attribute' : 'value', 'attribute' : 'value' }</attributes>
</meta>
*/
$data['attributes'] = json_decode($data['attributes']);
/*
Builds code.
*/
$data['code'] = smd_macro_build(
$data['macro_name'],
$data['attributes'],
$data['definition']
);
/*
Sanitize attributes
*/
$data['attributes'] = sanitize($data['attributes']);
/*
Give back in compiled row
*/
rah_flat::row($data);
}
Word flat makes me think pancakes (inner fatty). Just throwing all this madness out there. Or asking. Opinion. Directing people’s voice (does a person count as people?). Rah_flat itself is pretty complicated plugin (likely will never be even released as compiled plugin package as it requires advanced configuration, and is only meant for SVN/git/hg users). Dunno myself even, if smd_macro should take any action to support rah_flat. But yeah.
Last edited by Gocom (2012-02-20 20:38:14)
Offline
Re: smd_macro: Create custom virtual Txp tags that do stuff
Just an idea Stef:
<squid:stuff type="things" amount="lots">
...
</squid:stuff>
<squid:stuff type="non-things" amount="none" >
...
</squid:stuff>
As if to suppose txp
was not needed and squid
, shark
or any other thing would be fine.
I know the plugin uses <txp:
as do txp tags. That makes sense of course.
I guess my question is, can this plugin be altered to down to the level of offering a “squid templating system”? I know that sounds silly but the case might be: User base have profiles which act as mini-sites. A set of tags named in the likeness of the squid
name could be available to them as a means to do their own layouts and so forth. The vain pursuit of unified naming for a brand might benefit that brand from this type of detail. I know I’d try it.
Sorry if this is too far out there but it’s been scratching my noodle for a few days and I’m not ashamed to admit it.
An offshoot called smd_squid, if you like. :P
txtstrap (Textpattern + Twitter Bootstrap + etc…)
Offline
Re: smd_macro: Create custom virtual Txp tags that do stuff
mrdale wrote:
I think we should have a designated place where we could all share useful and somewhat general macros.
+1
This could easily be the wiki. (I put an empty page under the Community section of home page, if anyone wants to prime it.), but regardless of where it is, there should be a place. A new category in TXP Tips might also be a good place.
Right now I don’t think anyone is thinking of sharing macros because there’s no bazaar to do it.
Offline
Re: smd_macro: Create custom virtual Txp tags that do stuff
TXP Tips would be the right place. But without submissions I can’t do much. So if someone cares to send in their macro (or any other tutorials/tips) then I’d be happy to publish them and create new categories as needed.
Offline
#69 2012-11-30 20:22:38
- milosevic
- Member
- From: Madrid, Spain
- Registered: 2005-09-19
- Posts: 390
Re: smd_macro: Create custom virtual Txp tags that do stuff
jstubbs dijo:
But without submissions I can’t do much.
Here goes mine, I used it on several sites succesfully:
<txp:photo>
: a simple way to markup image layout within article body. The macro allows user to put images with 100% width, or X% width and aligned to left or right side. Optionally the user can ad a caption under the image.
How to use / Examples:
<txp:photo id="23" pos="left" caption="I am a photo aligned to left side"/>
<txp:photo id="23" pos="right" caption="I am a photo aligned to right side"/>
<txp:photo id="23" caption="I am a photo not aligned, I have 100% width"/>
<txp:photo id="23" /> <--(100% width and no caption)
Sample page using this macro: http://www.motorganga.com/classic-alforjas-y-bolsas-para-motos-custom
(the sample page use spanish words for the macro name, atributes and values son don’t search for “photo,left,right,caption” if you look at the page code. Also, the sample page use a bit more complex version of the macro, linking the images to another page: make your own superb photo macro version! )
Dependencies:
- You need to install chh_if_data plugin to detect caption optional atribute.
- You need some CSS to layout the result properly (example CSS at the bottom).
Attributes:
Name | Description | Default value | Replacement name |
---|---|---|---|
id | id of the image. | img_id | |
pos | desired position (left,right) by default not aligned, 100% width. | pos | |
caption | (optional) show a text under the image. | txt_caption |
Macro definition:
<txp:variable name="caption" value="{txt_caption}"/>
<div class="photo {pos}"><txp:image id='{img_id}' width="0" height="0" />
<txp:chh_if_data><span class="caption"><txp:variable name="caption"/></span></txp:chh_if_data>
</div>
Sample CSS (built your own version):
.photo {
width: 100%;
margin-bottom: 10px;}
.photo img{width:100%}
.photo.left {
float: left;
clear: left;
width: 30%;
margin: 0 3% 10px 0px;}
.photo.right {
float: right;
clear: right;
width: 30%;
margin: 0 0 10px 3%;}
.caption {
color: black;
display: block;
padding-top: 5px;
font-size: 9px;
font-weight: bold;
border-top: 1px dotted #E4E4E4;
line-height: 120%;}
{Edited to add some Textile. – Uli}
Last edited by milosevic (2012-12-03 06:39:53)
<txp:rocks/>
Offline
#70 2012-11-30 21:07:10
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: smd_macro: Create custom virtual Txp tags that do stuff
Thank you for your example, Jorge!
(I’ve put some more Textile in your post, e.g. tables need a starting and ending pipe character per line. Is everything displayed as you intended?)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#71 2012-11-30 21:23:32
- milosevic
- Member
- From: Madrid, Spain
- Registered: 2005-09-19
- Posts: 390
Re: smd_macro: Create custom virtual Txp tags that do stuff
Thanks to you, uli, and don’t doubt on change the text as necessary: my english is terrible! ;-)
I will try to publish a better sample online, but actually I don’t have a personal site for that kind of stuff.
<txp:rocks/>
Offline
Re: smd_macro: Create custom virtual Txp tags that do stuff
Thanks Jorge for your code example!! I have now taken the code and published it as Create custom virtual Textpattern tags.
Note that as of now I haven’t created an “smd_macro” category, but I can easily do so if there are more macros to publish.
Offline