Editing
Album Slugs
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
[[Category:CMS Documentation]] [[Category:Littled Libraries ]] [[Category:Web Development]] == Overview == Notes on the implementation of slugs—specifically for classes derived from the `album_class`—in the "littled" CMS system. == Workflow == === Back-end === * Include `/scripts/littled/gallery.js` on the page. * Within the record editing form, add a hidden input to pass along the class name to the AJAX script: <syntaxhighlight lang="html4strict"> <input type="hidden" name="type" value="<?=get_class($input) ?>" /> </syntaxhighlight> * On the record editing page, add handlers for the ''title'' and ''slug'' form inputs: <syntaxhighlight lang="javascript" highlight="5,7"> $(document).ready(function() { <? if ($input->id->value>0): ?> $('#pages-<?=$input->id->value?>').galleries('retrieveGallery'); <? else: ?> $('input[name="<?=$input->title->param?>"]').galleries('bindSlugWatch'); <? endif; ?> $('input[name="<?=$input->slug->param?>"]').galleries('bindSlugWatch'); $('.image-upload-container').galleries('bindImageOverlayHandlers'); }); </syntaxhighlight> ==== Overriding the default "title" property ==== In some cases the record doesn't use the default `album_class` property (`$title`) to generate the slug. The form input selector can be overridden using the `options` argument to `$.listings('bindSlugWatch')`. This needs to be done for both the "title" and the "slug" form input. <syntaxhighlight lang="javascript"> $('input[name="<?=$input->code->param ?>"]').galleries('bindSlugWatch', { edit: { id_param: '<?=$input->id->param ?>', title_param: '<?=$input->code->param ?>', slug_param: '<?=$input->slug->param ?>' } }); </syntaxhighlight> The derived class must override the `album_class::collect_slug_input()` to collect the values for the appropriate properties. <syntaxhighlight lang="php" highlight="9"> class DerivedClass extends album_class { /** * Override of album_class::collect_slug_input() to collect input for the * $code property instead of the album_class's $title property. */ public function collect_slug_input() { $this->title = &$this->code; parent::collect_slug_input(); } </syntaxhighlight> === Front-end === * Add rule to .htaccess for the content type. <br />The example here accommodates `ISAPI_Rewrite3` functionality. It could be written more intuitively for an Apache server. <pre> RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(characters|garden|sketchbook|storage)(.*) /$1/details.php [L,NC] </pre> '''Apache version.''' The first two lines test if the requested URI is a physical file on the server. The 3rd line skips the following RewriteRules if it is a physical file. (`[S=2]` where ''2'' is the number of lines to skip.) The following two lines handle the slug redirects. <pre> RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule .* - [S=2] RewriteRule ^characters(.*) /characters/ [L,NC] RewriteRule ^sketchbooks(.*) /sketchbooks/ [L,NC] </pre> == Examples == * littledamien.com: [http://littled.dbarchowsky.com/characters Characters CMS] ''(borrowing most of its functionality from the shared `album_class` resources.'' * littledamien.com: [http://littled.dbarchowsky.com/garden Garden CMS] ''(overriding the default source of the slug (using "common name" instead of "album title"))'' * littledamien.com: [http://littled.dbarchowsky.com/storage Storage CMS] ''(overriding the default source of the slug (using "package code" instead of "album title"))'' * littledamien.com: [http://littled.dbarchowsky.com/sketchbook Sketchbook CMS] ''(borrowing most of its functionality from the shared `album_class` resources.'' * damienjay.com: [http://damienjay.dbarchowsky.com/hostmgr/comics Comics CMS] ''implemented on the front-end also'' * damienjay.com: [http://damienjay.dbarchowsky.com/hostmgr/sketchboks Sketchbooks CMS]
Summary:
Please note that all contributions to Littledamien Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Littledamien Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information