Album Slugs: Difference between revisions
Jump to navigation
Jump to search
(Created page with "== Overview == Notes on the implementation of slugs—specifically for classes derived from the `album_class`—in the "littled" CMS system. == Workflow == === Back...") |
(No difference)
|
Revision as of 14:09, 16 November 2013
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.json the page. - Within the record editing form, add a hidden input to pass along the class name to the AJAX script:
<input type="hidden" name="type" value="<?=get_class($input) ?>" />
- On the record editing page, add handlers for the title and slug form inputs:
$(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');
});
- If the record doesn't use the default
album_classproperty ($title) to generate the slug, the form input selector can be overridden using theoptionsargument to$.listings('bindSlugWatch'). This needs to be done for both the "title" and the "slug" form input.
$('input[name="<?=$input->code->param ?>"]').galleries('bindSlugWatch', {
edit: {
id_param: '<?=$input->id->param ?>',
title_param: '<?=$input->code->param ?>',
slug_param: '<?=$input->slug->param ?>'
}
});
Front-end
- Add rule to .htaccess for the content type.
The example here accommodatesISAPI_Rewrite3functionality. It could be written more intuitively for an Apache server.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(characters|garden|sketchbook|storage)(.*) /$1/details.php [L,NC]
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.
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [S=2]
RewriteRule ^characters(.*) /characters/ [L,NC]
RewriteRule ^sketchbooks(.*) /sketchbooks/ [L,NC]
Examples
- littledamien.com: Characters CMS (borrowing most of its functionality from the shared
album_classresources. - littledamien.com: Garden CMS (overriding the default source of the slug (using "common name" instead of "album title"))
- littledamien.com: Storage CMS (overriding the default source of the slug (using "package code" instead of "album title"))
- littledamien.com: Sketchbook CMS (borrowing most of its functionality from the shared
album_classresources. - damienjay.com: Comics CMS implemented on the front-end also
- damienjay.com: Sketchbooks CMS