Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Widgets /

Discuss SilverStripe Widgets.

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

Help for widget open in new page


Reply


5 Posts   1531 Views

Avatar
webcook

Community Member, 20 Posts

1 June 2009 at 11:41pm

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
Avatar
webcook

Community Member, 20 Posts

2 June 2009 at 1:35am

hi experts

Please give some advice to my issue
Thanks

Avatar
dab

Community Member, 50 Posts

2 June 2009 at 7:14am

Edited: 02/06/2009 7:15am

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.

Avatar
webcook

Community Member, 20 Posts

2 June 2009 at 5:10pm

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 :D

Avatar
webcook

Community Member, 20 Posts

5 June 2009 at 11:05pm

hi many thanks its working.. :D