Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
mck_snippet
This plugin allow user insert into in a page some snippets text.
The principal function is mck_snippet that call the $Snippet global array with all record take from the db.
Into a CONTENT tab there is a one for manage all Snippets. For each Snippets you can chose to parse with Textile or use only brake at newline or unthouch the text.
Usage
After installing and activating the plugin you can insert function into page or form
This plugin use txp_user_public cookie, create also on Admin login.
Function and Attributes
<txp:mck_snippet>
Print the Body value of Snippet
- id: contain the unique id of Snippet
- title: contain the title of Snippet
Download
EDIT: v1.7.2 still available here (but broken in php 7).
EDIT II: v1.8.0 beta with preliminary fixes for txp 4.7+ and php 7 (admin side operation) here.
Release
mck_snippet 1.7.2
Last edited by MarcoK (2012-03-05 12:00:14)
Offline
#2 2012-03-04 19:46:38
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,311
Re: mck_snippet
Hi Marco,
thanks for making this plugin public. I’d find it super useful for giving website owners a certain level of interaction with the inner workings of my code (e.g. sorting categories for a category_list) without exposing the rest of it to potential damage, or for editing short notifications for the front side without risking the proper display of the website or confusing them too much by making these notifications from whole articles. That’s pretty cool!
I found, however, that it’s impossible to switch from textiling the snippet to “leave untouched”. No matter whether I edit an existing snippet or if I create a new one, the menu shows only “Textile” when I re-open the snippet.
When I use a snippet tag inside a section_list
tag, e.g. <txp:section_list sections='<txp:mck_snippet title="test"/>' />
I have to begin the content of the snippet with a comma, otherwise the first section won’t be displayed. The same is valid for the last section name: without a final comma the last section isn’t displayed. That’s probably too error prone for most of the users.
EDIT: just saw: a space at the beginning removes the need for a comma at the end. Space at the beginning? Reminds me of Textile. Are the two issues I described tied together?
Last edited by uli (2012-03-04 22:47:37)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: mck_snippet
uli wrote:
I found, however, that it’s impossible to switch from textiling the snippet to “leave untouched”. No matter whether I edit an existing snippet or if I create a new one, the menu shows only “Textile” when I re-open the snippet.
There are an isssue, now fixed, that when you reopen the snippet it will showed always textile. But however, the select showed also the other option. Now, if you select ‘leave untouched’, che option will be selected on reopening.
When I use a snippet tag inside a
section_list
tag, e.g.<txp:section_list sections='<txp:mck_snippet title="test"/>' />
I have to begin the content of the snippet with a comma, otherwise the first section won’t be displayed. The same is valid for the last section name: without a final comma the last section isn’t displayed. That’s probably too error prone for most of the users.
EDIT: just saw: a space at the beginning removes the need for a comma at the end. Space at the beginning? Reminds me of Textile. Are the two issues I described tied together?
Sorry Uli, i don’t understand what you mean. I have made some test and.. if i use <txp:section_list sections='<txp:mck_snippet title="test"/>' />
with test as sec1,sec2
or ,sec1,sec2,
I obtain the same result such as using <txp:section_list sections='sec1,sec2' />
or <txp:section_list sections=',sec1,sec2,' />
Last edited by MarcoK (2012-03-05 11:59:30)
Offline
#4 2012-03-05 13:55:24
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,311
Re: mck_snippet
Hey Marco, problem solved. Completely! Thank you very much!
I think the two issues had really been tied together, cause I can replicate the previous behavior: whenever I switch from “leave untouched” to Textile with the new version I have to use the space or the commas in order to have the desired output.
Thanks again, as well for the quick update :)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: mck_snippet
Released new version: 1.6
Now is integrated into txp 4.5
Last edited by MarcoK (2012-10-13 09:11:56)
Offline
Re: mck_snippet
Released new versione: 1.7
Now there is 4 more tags:
mck_snippet_zone
You can set some ‘zone’ on your website, and create some snippet for that zone.
mck_snippet_
and mck_snippet_body
if you would parse your snippet into a form.
mck_snippet_script
show script for manage snippet.
For me the best update is the possibility of edit in place each snippet: <mck_snippet editable="1" id="1" />
with double click edit in place this snippet.
If you use mck_snippet_zone
with mck_snippet_script
(required mck_login) you get on front-end two button for add new snippet in that Zone or manage existing snippet.
For each Zone, in admin section, you can sort all snippet simply with drag and drop (thank ad jquery.sortable())
Offline
Re: mck_snippet
Hi Marco ;)
You’re looking for, now you’ve got it:
#@public #@language fr-fr mck_snippet_tab => Snippets mck_snippet_markup => Contenu du Snippet mck_snippet_add => Ajouter un nouveau Snippet mck_snippet_code => Code du Snippet mck_snippet_no => Aucun Snippet enregistré mck_snippet_zone => Emplacement mck_snippet_no_zone => Aucun emplacement choisi mck_snippet_need => Un Snippet nécessite au moins un titre ou un n° d'ID mck_snippet_add_content => Ajoutez du contenu
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: mck_snippet
Thanks Patrick!!!
Updated at 1.7.1
Offline
Re: mck_snippet
Hi MarcoK,
thanks for this plugin. Really helpful when it comes to manage some micro-content here and there without the need to create a hidden section and (ab)use an article.
I’ve noticed that Textpattern tags inside an snippet aren’t parsed in a 404 page (not sure why, any ideas?).
I’ve found a fixed by changing a line in mck_snippet code:
At the end of the public mck_snippet
function, I’ve changed this:
return doTag(((@$thissnippet['snipEditable'])?'<div class="mck_snippet_editable" data-snipBody="'.$thissnippet['snipID'].'">'.$thissnippet['snipBody_html'].'</div>':$thissnippet['snipBody_html']), $wraptag, $class,'', $wrap_id);
to this:
return parse(doTag(((@$thissnippet['snipEditable'])?'<div class="mck_snippet_editable" data-snipBody="'.$thissnippet['snipID'].'">'.$thissnippet['snipBody_html'].'</div>':$thissnippet['snipBody_html']), $wraptag, $class,'', $wrap_id));
Basically, I’ve wrapped the full thing with the parse()
function, and now, the tags inside an snippet are parsed on a 404 page, and other “normal” (200) page are still working as expected.
So, if you find nothing wrong with this fix, could you make it into the next release?
PS: and now, a quick feature request: could you run update_lastmod()
(see here) whenever an snippet is updated? That will play nice with other plugins (ie. aks_cache) that rely on a change to the LastMod date do their magic.
Thanks.
Offline
#10 2017-02-07 09:06:36
- jpdupont
- Member
- Registered: 2004-10-01
- Posts: 752
Re: mck_snippet
Hello MarcoK !
On 4.6.2, the plugin don’t work, because mysql_ must be mysqli_.
My workaround : create the mck_snippet table in phpmyadmin.
This plugin must be in the core ! Thanks !
Have you some plan to release a txp 4.6.2 version ?
Offline
Re: mck_snippet
In the meantime, it seems that MarcoK has gone over to the dark side (😱) but I found an old copy of this on a subdomain of his.
I’ve had a go at fixing the broken installation routine, the tag registration and the panel errors in txp 4.7+ and if anyone’s interested, it can be found at github.com/jools-r/mck_snippet.
There’s still quite a bit I haven’t dealt with, including admin-side sorting and front-side editing which I never tried in the original (it may or may not work), and there are still some minor admin-side display glitches but the basic functionality is restored.
I’m not sure if I will pursue those any further so any contributions are welcome.
If you’re testing txp 4.8, installation is very easy. Place the whole mck_snippet
folder in /textpattern/plugins
(or wherever the plugins folder may be moved eventually), visit the Admin › Plugins panel and import the plugin.
Both MarcoK’s original plugin and my preliminary-fix-repo are linked in the original post.
TXP Builders – finely-crafted code, design and txp
Offline
Re: mck_snippet
Admittedly, I always felt that we could acheive this kind of functionality using the output_form
tag but since shortcodes became part of the core, it also added some steroids. Is this plugin actually needed in the current txp installs?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline