Jump to:

23483 Posts in 18976 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » shortcodehandler displaying page variables

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1106 Views
  • Borto
    Avatar
    Community Member
    2 Posts

    shortcodehandler displaying page variables Link to this post

    In order to make it possible to display some module-output in the middle of a $Content-block I have successfuly created a shortcodehandler.

    The shortcodehandler displays the dataobjects like we expected, execpt for one thing. We would like to use the page variables of the page on which the shortcode is called.

    We would like to use $URLSegment and display the pagetitle in the shortcode template. Is this possible in some way? Because the shortcodehandler is not defined in the page controller the $this-variable is not available.

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: shortcodehandler displaying page variables Link to this post

    I think Controller::curr() is what you need.

    if($c = Controller::curr()){
    $currentPageID = $c->ID;
    }

  • Borto
    Avatar
    Community Member
    2 Posts

    Re: shortcodehandler displaying page variables Link to this post

    Thanks, just what I needed.

    Problem solved.

  • LinseyM
    Avatar
    Community Member
    99 Posts

    Re: shortcodehandler displaying page variables Link to this post

    Hi there, I posted this up on SSBits too, but just in case...

    Can anyone help me with how to use "Controller::curr()", as mentioned in the SSBits tutorial please? http://www.ssbits.com/tutorials/2010/2-4-using-short-codes-to-embed-a-youtube-video/

    I've got "ClientYouTubeID" as a page variable, rather than as part of the ShortCode, so I need to be able to call the variable $ClientYouTubeID within my YouTube.ss template, and I don't understand how to do it. At the moment it just doesn't return anything.

    Thanks!

    1106 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.