hello,
ok, this is what I did to add a custom segment url to handle the roman character counterpart of the arabic title:
I added a database field and a textfield to managed it in the cms. The generateURLSegment() function now takes AlbumURL value instead of AlbumName value.
../image_gallery/code/ImageGalleryAlbum.php :
<?php
class ImageGalleryAlbum extends DataObject
{
static $db = array (
'AlbumName' => 'Varchar(255)',
'AlbumURL' => 'Varchar(255)', // added new database field
'Description' => 'Text'
);
....
....
....
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('AlbumName', _t('ImageGalleryAlbum.ALBUMTITLE','Album Title')),
new TextField('AlbumURL', _t('ImageGalleryAlbum.ALBUMURL','Album URL')), // added new textfield
new TextareaField('Description', _t('ImageGalleryAlbum.DESCRIPTION','Description')),
new ImageField('CoverImage',_t('ImageGalleryAlbum.COVERIMAGE','Cover Image'))
);
}
....
....
....
function onBeforeWrite()
{
parent::onBeforeWrite();
if(isset($_POST['AlbumURL'])) { // 'AlbumName' replaced with 'AlbumURL'
$clean_name = SiteTree::generateURLSegment($_POST['AlbumURL']); // 'AlbumName' replaced with 'AlbumURL'
if($this->FolderID) {
$this->Folder()->setName($clean_name);
$this->Folder()->Title = $clean_name;
....
....
....
?>
So far this works fine for me. I'm not sure however if it's the best way. I'm waiting for UncleCheese to confirm.
thanks
Said