Thoughts on achieving subpage-specific editable slots within an engine

2 views
Skip to first unread message

Tom Boutell

unread,
Dec 16, 2009, 7:18:53 PM12/16/09
to pkcont...@googlegroups.com
I wrote this in response to a particular user this morning and felt it
would be helpful to others.

* * *

Check out the CMS documentation, in particular the sections on how
to create custom slots and how to create "engines," normal Symfony
modules that bolt into the CMS page space wherever you want them and
intercept all URLs that begin with the URL of the engine page, running
them through a set of routes assigned to that engine to decide what to
do. This is a powerful feature that should allow you to integrate any
custom functionality you might wish.

In general, when you want to be able to embed something
application-specific in a regular CMS page, use a custom slot. When
you want to create a subsection of your site that participates in CMS
navigation but takes over the whole page and even virtual "subpages"
of that page, use an engine.

When working with engines, keep in mind that slot names can be
created dynamically. That means that if your engine has "subpages"
that are not CMS pages in the conventional sense, you can still put
distinct slots on those subpages by using appropriate slot names. For
instance, if you create a module called 'houses' to deal with real
estate listings and you've put that on an engine page here:

/house

And that module has a pkContextCMSDoctrineRoute called 'my_house_route' that
shows an individual house based on its Doctrine ID as part of the URL:

/house/37

And you want an editable CMS content area for each house, your
template can just take the ID into account and call that slot
'house-description-37' when calling pk_context_cms_area() and you're
off to the races. As far as the CMS is concerned all of these slots
"live" on the engine page /house, but you present them only on the
engine-generated subpages that make sense.

If you ever need to mop them up later, in the delete() method of your
House class for instance, you can delete the appropriate
pkContextCMSArea objects:

Doctrine::getTable('pkContextCMSArea')->createQuery(a)->where('a.name
= ?', 'house-description-' . $this->id)->delete();

This should automatically clean up the rest of the table rows
associated with those area names in any page, via ON DELETE CASCADE.

(In some situations you may find it easier to use global slots rather
than slots which are attached to an engine page. The same techniques
still apply.)

--
Tom Boutell
P'unk Avenue
215 755 1330
punkave.com
window.punkave.com

Reply all
Reply to author
Forward
0 new messages