1. May 26 2008

    I upgraded my Silverstripe install to the latest 2.2.2 version and migrated the blog from just custom code pages to the article module I wrote, which has a few advantages.

    Big chance some things might still be broken or behave strange. I had a few hacks in the core which I didn't re-apply, so if you notice anything weird, please tell me.

    Permalink

  2. One of the biggest inconveniencies in the current Silverstripe versions imho, is that there is no way to limit the amount of subpages that the cms displays in its hierarchical tree.

    Now in most cases for simple websites, this isn't a problem at all. The problem arises when you're having a blog or a news site that can run into hundreds of subpages of the same parent. It may cause the admin to load very slow, and once loaded, you'll have to scroll down as they're displayed in one long list. Imagine this with like 3000 pages. Right, a problem. This problem has been discussed already in the Silverstripe forums, and some conceptual solutions have been talked about.

    Thing is, the best solution would require a lot of code to be rewritten and a very solid understanding of the internals of Silverstripe. As working out the suggested idea is a bit too much work and in my opinion better left to the core developers, I created a possible dirty, but easy solution for this.

    With my solution, you'll get an extra field in the behaviour tab, which requires you to set a number. This number defaults to 0, which means: just do nothing and keep it how it is. Once you set a number, you'll have to refresh the page, and the cms will then display for that page only the amount of subpages you set in the parent. So, when set to 20, it will only show the last 20 subpages you created in the cms. Note that this will make you lose the drag 'n' drop ordering you may have set for these subpages. It will sort on 'Created'. (Although you could probably easily add another textfield to make the sort filter adjustable as well.) You can still use the cms search functionality, which will display all results, not using the limit.

    The first change you'll have to make is in sapphire/core/model/SiteTree.php.
    Add the next line to the static $db array (this will be around line 95 somewhere):

    "NumberCMSChildren" => "Int(0)" 

    Then scroll down in SiteTree.php until you find the code that says:

    new TextField(
                            "HomepageForDomain",
                            _t('SiteTree.HOMEPAGEFORDOMAIN', "Domain(s)", PR_MEDIUM, 'Listing domains that should be used as homepage')
                        ),

    Add this beneath it:

    new NumericField(
                            "NumberCMSChildren",
                            "Total displayed subpages in CMS (must be numeric, defaults to 0 == all, page refresh required after changing this)",
                            $this->NumberCMSChildren
                        )

    Make sure you don't mix up any braces or comma's, or you'll get an error. 

    Then open up sapphire/core/model/Hierarchy.php, scroll down to around line 493 where you find the method stageChildren(), like:

    public function stageChildren($showAll = false) { 
    ...
    }

    Then, replace this complete function with:

    public function stageChildren($showAll = false) {
    $extraFilter = $showAll ? '' : " AND ShowInMenus = 1";
    $baseClass = ClassInfo::baseDataClass($this->owner->class);

    # defaults
    $limit = "";
    $sort = "";

    # check if the request comes from the cms-admin section, allow for content and getsubtree only
    $cms = preg_match("/admin(\/)?$/", $_SERVER['REQUEST_URI']) || preg_match("/admin\/getsubtree/", $_SERVER['REQUEST_URI']);

    # get limit
    $limit = $this->owner->NumberCMSChildren;

    # if limit is 0, default to all, or if limit ok, but cms filter false, default to all
    if(!$limit || (!$cms && $limit)) $limit = "";

    # if all good, make sort so it takes the last ones
    if($cms && $limit) $sort = "Created DESC";

    # get set
    $set = DataObject::get($baseClass, "`{$baseClass}`.`ParentID` = " . (int)$this->owner->ID . " AND `{$baseClass}`.ID != " . (int)$this->owner->ID . $extraFilter, $sort, "", $limit);

    # if set, cms and limit, we need to resort to have the last one on bottom
    if($set && $cms && $limit) $set->sort("Created ASC");

    return $set;
    }

    This hack works because it detects where the request comes from, but then again, this is what makes it a bit a dirty hack too. It will only work if you didn't change the default admin url. This solutions seems to work perfect for me, but only use it after you tested it yourself, I can not be hold responsible if it turns out to break something. So far I haven't encountered any problems, but never say never.

    It's a short hack, and hopefully it will be useful. Comments, improvements (I'm sure there are), suggestions... welcome. 

    Permalink

  3. Mar 4 2008

    I just want to apologize for probably the only post this month. I've been nothing but busy lately, working on some projects for a UK - based company called GPMD that builds Silverstripe websites, which is a good thing of course.

    Those of you that do have time in abundance, why not visit the Game is up! festival which will be held in Vooruit around these days.

    Cheerz! 

    Permalink

  4. As Silverstripe currently doesn't have built - in support for pinging services like technorati or weblogs, I created a little widget that makes this possible. 

    Ping Widget

    Installing it is pretty easy: 

    1. Download the zip file and extract it to the root of your SS-installation.
    2. Run db/build.
    3. Go to the cms and select the root of whatever page-type you're publishing children on. If you're using the standard blog module, this would be the 'Blog' page.
    4. Choose the widgets tab, and drag the widget to the right to enable it. Save and publish the page.
    5. The widget is now working.

    Everytime a child page of the page where the widget is on gets published, it can ping technorati, weblogs and pingomatic. It makes use of 2 little external libraries (weblog_pinger and xmlrpc). Note that you don't need to download the libraries, they are already included in the widget.

    To use SS widgets on your page (articleholder, blogholder, whatever) , make sure you have attached a widgetarea in your pageholder/articleholder/... model:

    static $has_one = array( "WidgetArea" => "WidgetArea" );

    function getCMSFields()
    {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("WidgetArea"));
    return $fields;
    }

    Hope this is useful for someone. Let me know if you find any bugs or things that I might have overlooked.

    Permalink

Mailing List

Subscribe to get new posts in your mailbox!

Del.icio.us

DownUp
  1. YouTube - Rising_Yoshida Brothers
  2. What I Hate About Becoming a Designer | Jeremy Adam Davis
  3. Web Design Blog: Web Design & Innovation in web standards : Viget Labs
  4. De Morgen: Economie - Vier op vijf Belgen zien toekomst donker in (332188)
  5. Yes, you found us! Too bad! - Home
  6. Pluit Solutions » Blog Archive » PNG Image Fix For IE
  7. Carectomy.com: Removing Cars from People - All Aboard the Train that Never Stops!
  8. BBC NEWS | Have Your Say | Spreading peace over the net
  9. Pictures From the Sky
  10. remiq.net : (America), (car), (dog), (motivator), (US)This is why the world hates you …
  11. TinyPaste
  12. Icojoy - stock icons shop, icons blog, free icons
  13. The Website Is Down
  14. Shell Command - Remove SVN Folders - Jon Galloway
  15. Stuck in Photos - Helga Kvam and Völundur Photograph Iceland
  16. 1% For the Planet
  17. YouTube - Open Source, pants optional
  18. Welcome to Agavi!
  19. your enemy's enemy is your friend | <3 ifhy
  20. Hatebook – Welcome to Hatebook
  21. UI-patterns.com
  22. 30 Useful PHP Classes and Components « PHP::Impact ( [str blog] )
  23. Ik zoek huis.Ik zoek een huis. …
  24. Uw online wijnwinkel... Vinoshop.be - VinoshopMooi mooi …
  25. Design the content - Wolf’s Little Storewe're still far from there... …
  26. YouTube - Cell Phone In MicrowaveIt's evil I tell ya... …
  27. Insects/Spiders - a set on Flickr
  28. Everybody | Faviki - Social bookmarking tool using smart semantic Wikipedia (DBpedia) tags
  29. BIGGEST DRAWING IN THE WORLD
  30. 13 free CMS options for Web Design Professionals Reviewed
  31. [Re]Encoded dot Com » Blog Archive » 42 Awesome Business Card Designs (With Links to 100s More)