Jump to:

791 Posts in 369 Topics by 303 members

Widgets

SilverStripe Forums » Widgets » Help for widget open in new page

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 1426 Views
  • webcook
    Avatar
    Community Member
    20 Posts

    Help for widget open in new page Link to this post

    Hi experts,

    here with attache my jpeg image.

    I query is .. i have created one widget .It shows in pages.When i click the widget it must open in new page.
    Now i cant able to show in seperate page. how to create my widget holder page.

    Please give some advice.
    Thanks

    Attached Files
  • webcook
    Avatar
    Community Member
    20 Posts

    Re: Help for widget open in new page Link to this post

    hi experts

    Please give some advice to my issue
    Thanks

  • dab
    Avatar
    Community Member
    50 Posts

    Re: Help for widget open in new page Link to this post

    Hello,
    <br >as i understand - you want make page wich will contain your widget as page content.
    <br >Therefor you should make new page type, for instance HomePage.php:
    <br >

    <br ><?php
    <br >class HomePage extends Page {
    <br > static $db = array(
    <br > );
    <br > static $has_one = array(
    <br >      "Widget" => "WidgetArea",
    <br > );
    <br >
    <br >   function getCMSFields() {
    <br >      $fields = parent::getCMSFields();
    <br >      $fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("Widget"));
    <br >      return $fields;
    <br >   }
    <br >
    <br >}
    <br >
    <br >class HomePage_Controller extends Page_Controller {
    <br >}
    <br >?>


    <br >
    <br >and then you should make new layout for your HomePage, it should be HomePage.ss inside your Layout folder:
    <br >

    <br ><div class="typography">
    <br >      <h2>$Title</h2>
    <br >
    <br >      $Widget
    <br >
    <br >      $Content
    <br >      $Form
    <br >      $PageComments
    <br ></div>
    <br >


    <br >
    <br >Hope it will help.

  • webcook
    Avatar
    Community Member
    20 Posts

    Re: Help for widget open in new page Link to this post

    hi

    many thanks for your reply.

    I widget i passed the query string like still i cant able to view in new page..

    Please tell me how to pass the query string in the widget.

    http://localhost/pro/Projects/mywid/Story?id=2&action_results=Story

    Like this i pass the widget query string
    <% if MyStory %>
             <% control MyStory %> $Link
                <a href="Story?id=$ID&action_results=Story">$Desc</a><br>
    (Please tell me how to pass the widget query string)
             <% end_control %>
             <% end_if %>

    THis is my NewStoryWidgetHolder page,
    <?php
    /**NewStoryWidgetHolder
    * Defines the ArticlePage page type
    */

    class NewStoryWidgetHolder extends Page {
    static $db = array(
    );
    static $has_one = array(
    "Widget" => "WidgetArea",
    );

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

    }

    class NewStoryWidgetHolder_Controller extends Page_Controller {

       function Story()
       {
          return 'srg';
       }
    }

    ?>

    Once again thanks

  • webcook
    Avatar
    Community Member
    20 Posts

    Re: Help for widget open in new page Link to this post

    hi many thanks its working..

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