Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-09-15 13:24:22

FireFusion
Member
Registered: 2005-05-10
Posts: 698

[request] Template content snippets - Keep clients away from the backend

Often I have bits of content hard coded into the the templates that I want the client to be able to edit easily without breaking their site!

The plugin I have in mind would work like the snippet function in the MLP. In a form or page template i’d put something like…

<div class="copyright"><h5>{{Company Name}}</h5> {{copyright}}. <a href="{{Email address}}">Email Us</a></div> 

The end user would see a new tab (under the content section) that automatically finds these snippet names I’ve put in the templates and allows you to assign text to them (like MLPs snippet function). They can then easily edit them…

Copyright
[Text box]

Email address
[Text box]

Company Name
[Text box]

Offline

#2 2008-09-15 13:41:00

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: [request] Template content snippets - Keep clients away from the backend

FireFusion wrote:

Often I have bits of content hard coded into the the templates that I want the client to be able to edit easily without breaking their site!

I’ve had the same thoughts. I’ve been tinkering with an idea to make use of the new <txp:variable/> tag in 4.0.7 but have a plugin manage the values.

Offline

#3 2008-09-15 13:53:52

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: [request] Template content snippets - Keep clients away from the backend

Nice. That would be killer – Especially if there was a way to add/remove variables (Publisher privs only of course).
4.0.7! 4.0.7! 4.0.7! [insert crowd going wild here]

)

Offline

#4 2008-09-15 14:16:41

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

Re: [request] Template content snippets - Keep clients away from the backend

My still-in-beta plugin smd_vars does something like that, although it’s on the ‘extentions’ tab and all the vars are defined there. I guess there’s no reason it couldn’t be moved to the Content tab and/or the functionality split between two tabs. At the moment, vars can be added either via the back-end or from the page on-the-fly so it might not be what you want right now. Of course, with a little extra privs coding…

Let me know if you think some variant of that would be useful, or if someone should have a go at ripping my code apart and making a dedicated plugin just for client content.

EDIT: the replacement system right now is via a tag. Of course there’s no reason it couldn’t be via some kind of {variable} as has been done with wet_for_each_image, then stolen mercilessly by me and used in smd_gallery, smd_if, smd_each, smd_query, etc. It’s perhaps more messy (variable clashes are a problem unless prefixed) but doable.

Last edited by Bloke (2008-09-15 14:22:32)


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

#5 2008-09-15 14:16:53

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

Re: [request] Template content snippets - Keep clients away from the backend

@FireFusion:

great minds think alike!

Let’s start with the feature idea:
On “Presentation” -> “Forms”, we have the drop-down to pick up the form type. If you ever wonder how this option affects the functionality of a form, the answer is: it doesn’t. It’s just there for “classification” purposes, and then the Tag Builder also uses this classification.

What if we (well, devs) add a new type named “snippet”? Then, a form classified as “snippet” will be editable directly from “Content” -> “Snippets” (a new tab similar to “Presentation” -> “Forms”).
With the help of upm_textile, forms can be written using Textile, as if they were an article.

Even in the “worst” case when your client needs to edit a more complex “snippet” form (a complex footer, a complex navigation, using HTML and/or TXP tags), you know they can’t access to the “Presentation” tab, nor they can edit any form that isn’t marked as “snippet”.

I could go further… and see this “Snippet” tab not related (internally) at all to “forms”. Just a new tab/db-table, similar to articles, but simpler, not tied at all to sections/categories, nor time, nor status. A “snippet” could be a input-field or a textarea. Nothing more.

This is almost similar to the “Snippet” concept on the MLP.

I’ve posted the above on this thread few weeks ago.

The idea is to have a new kind of content (little snippets, like footer content, or even content used by other plugins) that aren’t articles, but that end users (clients) should be able to edit.
Firefusion’s approach (using some kind of variable) seems to be is less prone to errors (broken HTML, usually) but less flexible at the same time.
What I suggested is more flexible, but then, clients could break things, if not done properly.
But then, this “snippets” could be forced/escaped to be plain-text/textile only, and then be used inside a complex TXP/HTML form (which client couldn’t edit).


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2008-09-15 14:23:53

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Re: [request] Template content snippets - Keep clients away from the backend

I really think it should be just variables without allowing HTML. If the client knows any HTML there generally isn’t a problem with them going in the backend.

Glad everyone is keen :)

Last edited by FireFusion (2008-09-15 14:25:06)

Offline

#7 2008-09-19 04:04:12

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: [request] Template content snippets - Keep clients away from the backend

renobird wrote:

Nice. That would be killer – Especially if there was a way to add/remove variables (Publisher privs only of course).

I’ve tinkered some more and come up with a plugin: adi_variables. It can be installed in any version of TXP but, obviously, can only be used in anger in 4.0.7. It’s beta and the help is non-existant but it should be straightforward to use.

It gives you a new tab under content for managing variables. These variables are stored in a form called adi_variables (which is automatically created). To bring them into operation put <txp:output_form form="adi_variables" /> in your 4.0.7 pages (typically at the top).

Because TXP variables have been implemented as a tag and hence used in forms/pages etc the distinction between “admin” and “public” kicks in a long way down the food chain. Basically anybody, apart from Staff Writer & Freelancer, has access to Forms – so it’s only these two user privs that I’ve restricted.

There is an alternative method of storing the variables (i.e. in the database) which would introduce a greater level of protection but I’d be interested in what people think so far.

Offline

#8 2008-09-19 14:34:06

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: [request] Template content snippets - Keep clients away from the backend

gomedia,

Nice. I’ll give it a shot later today.

Offline

#9 2011-05-03 22:19:30

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,091
Website Mastodon

Re: [request] Template content snippets - Keep clients away from the backend

Hi -I am looking for a way to have a few snippets on our web page and was wondering if there is a cool nifty “something” that i can use with 4.4.0?

We need to show a couple of sentences n about three <Divs> but I would like to find a solution that will allow an editor to update them easily.


…. texted postive

Offline

#10 2011-05-04 00:43:49

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [request] Template content snippets - Keep clients away from the backend

bici wrote:

Hi -I am looking for a way to have a few snippets on our web page and was wondering if there is a cool nifty “something” that i can use with 4.4.0?

Some to choose from:

Offline

Board footer

Powered by FluxBB