Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Duplicate links in album page

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 917 Views
  • sajok
    Avatar
    Community Member
    82 Posts

    Duplicate links in album page Link to this post

    hello,

    I have installed the Image gallery module in a multilingual website with Arabic as the default. I created two albums in cms in Arabic names, and when I view them in front-end both album's names get the same url like : mysite.com/gallery/album/-
    when I renamed albums to English, each album get it own url like: mysite.com/gallery/album/album1, mysite.com/gallery/album/album2 .. so it seems that Arabic characters are not recognized by the script, and instead they are replaced by a dush for both album names. I checked the tables collation and they are set to utf8..

    anyone knows how to correct this?! I appreciate your help..

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: Duplicate links in album page Link to this post

    This is not an Image gallery module problem, the problem is how the CMS handles page title conversion to URL:s. If you're writing pages in a language that doesn't have English characters in it then you will have to give these pages an URL yourself on the Metadata tab.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Duplicate links in album page Link to this post

    That's exactly right, Smurkas. It looks like we will have to add a custom album url segment to this module to handle the roman character counterpart of the title.

  • sajok
    Avatar
    Community Member
    82 Posts

    Re: Duplicate links in album page Link to this post

    @samukas, thank you for replying.. I created a page "gallery-page" and it has the Metadata tab option, whereas sublinks "albums" their links are generated by taking the album name as the url, and I can't see any Metadata option like the parent page!
    @UncleCheese: that's exacly what we need, a custom url option like in parent pages. Now I have album names in arabic and link to the same page, I would appreciate if there is a fix for now..

    Thank you

  • sajok
    Avatar
    Community Member
    82 Posts

    Re: Duplicate links in album page Link to this post

    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

    917 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.