Appending lines to meta/head text from content block

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
Timberline
New Member
New Member
Posts: 6
Joined: Tue Nov 11, 2014 6:43 pm

Appending lines to meta/head text from content block

Post by Timberline »

I'm looking for the canonical way to take advantage of the content block being processed ahead of the head block to let a UDT or other tag in the content block append additional styles or scripts to a page's head block at runtime.

My fallback method would be to have one or more placeholder tags templated into the head block that examine variables set by the worker tag in the content block. Obviously this isn't just for the thrill of doing it; I'd take a more static approach if it were appropriate in the larger context.

Is this fallback method in fact the best way of accomplishing that? Or what should I be exploiting something in the API to do it programmatically? I have looked at the docs and examined the particular contentObject in question, but so far I don't see a more straightforward solution.

(FWIW I notice most of the big news sites don't even bother putting such item-related data in the head block any more but inject it into the middle of the body text just before using it.)
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Appending lines to meta/head text from content block

Post by Dr.CSS »

Have you tried the metadata box in the Options tab of the page..?
Timberline
New Member
New Member
Posts: 6
Joined: Tue Nov 11, 2014 6:43 pm

Re: Appending lines to meta/head text from content block

Post by Timberline »

Thanks for getting back, but the metadata in question isn't always known at edit time, and in any case the tag implementing this needs to be more plug-and-play in the content block than that.

I've proceeded with two tags in the template, each inspecting a session variable for run-time additions to styles or js requested by tags in the page content. After more investigation, that seems to be the simplest and most direct method.
Post Reply

Return to “The Lounge”