The Joomla! Forum ™

Forum rules

Please use the mailing list here: rather than this forum.

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Mar 05, 2013 3:39 pm 
Joomla! Guru
Joomla! Guru

Joined: Fri Aug 19, 2005 9:27 am
Posts: 527
I wasn't sure where to post this because it's more of an abstract idea than something that applies to a specific Joomla version. Call it a suggestion, an example, a new feature, whatever. So, mods, feel free to put this where you want.

When I say document containers, what I'm really talking about is all those arrays in the document model that store things like metas, scripts, css, etc.

About a year ago, I was working on a project using another framework. Being used to Joomla's document object, I wanted something that would mimick that. It needed all the typical containers - document type, language, title, css, scripts, etc. But what I also wanted was a way to prepend an item to a container. I tried various array handling techniques and somewhere along the way stumbled upon the ArrayObject. It wasn't so much the ArrayObject that caught my attention as it was what was missing - appending an item to the object. Fortunately, I found an example of how to do that. What I wound up with was a model where the containers were ArrayObjects instead of simple arrays. Plus, as objects, I can chain methods like this"
And then somewhere along the way, maybe I need to prepend a script or css or meta for whatever reason. I can do this:
Why would I make the title a container? Maybe I wanted to append something to it:
$document->appendTitle(' : page 2');
Now I have "Site : page 2". But maybe along the way I want to prepend as well:
$document->prependTitle('Company : ');
Now I have "Company : Site : page 2". Ok, maybe that's a little overboard but you get the idea.

So what does all this have to do with Joomla? First, I'd really like to see the ability to prepend items to some of the standard containers like scripts and css. I'd also like to see a container we can use just before the body close tag. Of course, method chaining is also a really nice feature.

Using a technique like this, we gain a lot of flexibility. Especially when it comes to extensions and how they interact with the document model and in particular how we render the head tag.

So, here's a link to the document container I used on that project:

Have a look, dig around, think about whether any of that stuff might work for Joomla. It was just an idea at the time and wound up hugely beneficial to my project.

Al Warren
This ain't my first rodeo. Red Foreman says it best.

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 9 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group