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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

SILVERSTRIPE BOOK XML SITE TREE ISSUE


Go to End


40 Posts   6701 Views

Avatar
servalman

Community Member, 211 Posts

27 August 2010 at 7:16pm

Edited: 27/08/2010 7:22pm

Hi Banal

I'm sure you'r right and that I over complicate things and that template language and logic is more sipmle than what I think.

But I made progress like I'm using swfobject like you said and it works like a charm .

Regarding the site tree (my nightmare):
At first wanted to retrieve it tottally then I realised that it would be (even in the flash file) much easier for me if I could just retrieve the section that is currently visible on screen and use it in my flash layer instead of processinf the all tree.

I just tried to create:

templates/export/ExportProductPage.ss with this in it :

<node id="$ID" label="$Title" link="$Link" classname="$ClassName">
   <% control Children %>
   $ExportContent
   <% end_control %>
</node>

but I get the same results :

If I do :
http://mysite/products/productname/show/export
i get the error
user_error("DataObject::get_by_id passed a non-numeric ID #$id", E_USER_WARNING);

If I do :
http://mysite/products/productname/show/5/export
i get the regular page

If I do :
http://mysite/products/productname/export
i get the error :
Action 'export' isn't allowed on class ProductPage_Controller

What I dont get is that with the other export it works fine but here if I do $Link/export it would mean in my case :

http://mysite/products/productname/show/5/export

And in your example (the html one ) it seems that by juts creating "templates/export/ExportPageTemplateName.ss it should work.

I think I missed something topugh I'm really trying to undertstand the process and I read it carefully.

Thank again if you can explain me

Attached Files
Avatar
bummzack

Community Member, 904 Posts

27 August 2010 at 8:00pm

I still don't get what this whole product stuff is about.
You want an XML output for one product? And the product is a DataObject?

If that's the case, create a function like this in your ProductPage_Controller:

public function productxml(){
	$id = (int)Director::urlParam('ID');
		
	$obj = DataObject::get_by_id('Product', $id);
	return $obj->renderWith('ProductXML');
}

And create a template templates/ProductXML.ss that will be used to render your product.

Then to get XML for a product with a given ID, use:
mysite.com/pathto/productpage/productxml/ID

The green part would be the URL of your ProductPage and the red part should be replaced with the ID of the Product DataObject you want to display.

Since apparently you don't need to export the Site-Tree several levels deep, you could basically skip all that stuff you did before. As I said, I think you're doing things way too complicated right now because your requirements shifted quite a bit.

Avatar
servalman

Community Member, 211 Posts

27 August 2010 at 8:18pm

Hello Banal

Really hope I'm not bothering you to much.

I made an image wich I think is going to make thing clearer:

Each of my product as a page in the site tree.

What I want is exactly the same thing as in the example that works now the xml I use is very short .

I just need the site tree because only the nav will be in flash

Hope it can help you to help me

Thanks

Attached Files
Avatar
bummzack

Community Member, 904 Posts

27 August 2010 at 9:48pm

Edited: 27/08/2010 9:49pm

It should be as simple as calling:
<URL OF "sahos by evidence" Page>/export

And:
<URL OF "Les Démaquillants & Nettoyants" Page>/export

Important: Use <% control Children %> instead of <% control Menu(2) %>!

Avatar
servalman

Community Member, 211 Posts

28 August 2010 at 3:20am

Edited: 28/08/2010 3:21am

Hi Banal

I think I'm lost now

This is working for the saho part

in template/Page_export.ss

<?xml version="1.0" encoding="UTF-8"?>
<% control Parent %>
<node id="$ID" label="$Title" link="$Link" classname="$ClassName">
<% end_control %>
<% control Menu(2) %>
$ExportContent
<% end_control %>
</node>

in template/export/ExportPage.ss

<node id="$ID" label="$Title" link="$Link" classname="$ClassName">
   <% control Children %>
   $ExportContent
   <% end_control %>
</node>

if i use the URL :http://mysite/sahos-by-evidens/saho-purifiant/export
(I get this URL because "sahos-by-evidens" is a redictor page wich links to saho-purifiant.)

I get exactly what I want The root node is the parent node and the rest are the childnode of my site tree.

<?xml version="1.0" encoding="UTF-8"?>

<node id="31" label="SAHOS BY EVIDENS" link="/evidev/sahos-by-evidens/saho-purifiant/" classname="RedirectorPage">


<node id="36" label="Saho Purifiant" link="/evidev/sahos-by-evidens/saho-purifiant/" classname="EditorialPage3">
   
</node>

<node id="37" label="Saho Nourrissant" link="/evidev/sahos-by-evidens/saho-nourrissant/" classname="EditorialPage3">
   
</node>

<node id="38" label="Saho Perfection" link="/evidev/sahos-by-evidens/saho-perfection/" classname="EditorialPage3">
   
</node>

<node id="39" label="Saho Eclat" link="/evidev/sahos-by-evidens/saho-eclat/" classname="EditorialPage3">
   
</node>

<node id="40" label="Saho sur mesure" link="/evidev/sahos-by-evidens/saho-sur-mesure/" classname="EditorialPage2">
   
</node>

</node>

now if in template/export/ExportProductPage.ss I write

<node id="$ID" label="$Title" link="$Link" classname="$ClassName">
   <% control Children %>
   $ExportContent
   <% end_control %>
</node>

If I use the URL
http://mysite/nos-soins/les-d-maquillants-nettoyants/le-lait-demaquillant/export
I get this URL because "nos-soins" & "les-d-maquillants-nettoyants" are both redictor page wich links to le-lait-demaquillant.

I get an error

Action 'export' isn't allowed on class ProductPage_Controller

I don't understan why

Thanks in advance if you have a clue

Avatar
bummzack

Community Member, 904 Posts

28 August 2010 at 4:28am

That looks like a permission problem..
1) Make sure, you don't have a function called "export" in ProductPage_Controller.
2) Make sure that none of your pages URL-Segment is called export
3) If the above didn't change anything, add the following to your Page Controller:

static $allowed_actions = array(
	'export' => true
);

Since both of your "export" actions are going to use the Page_export.ss template, you have to modify it so that it works for both cases? Something along the lines of:

<?xml version="1.0" encoding="UTF-8"?>
<node id="$ID" label="$Title" link="$Link" classname="$ClassName">
<% control Children %>
$ExportContent
<% end_control %>
</node>

Then use these URLs:

http://mysite/sahos-by-evidens/export

http://mysite/nos-soins/les-d-maquillants-nettoyants/export

Avatar
servalman

Community Member, 211 Posts

28 August 2010 at 5:50am

IT's Working !!

Permission was the key .

I added this

static $allowed_actions = array (
'show',
'export' = >
);

Now for the output I'm going to tweak the Page_export.ss

so it outputs what I want depneding on the level with some if statement.

I really apreciated what you did for me and I will tel you know how it goes.

Thanks again

Avatar
servalman

Community Member, 211 Posts

14 September 2010 at 8:47pm

Hello Banal ;)

It's me again with my XML problems

I had to put this on stand by for a while but I'm back on it.

Now I have no problem getting my product (on my screenshot the ProductsMenu zone) as an xml output .

As you know I want to divide my site tree into small parts so know I want to be able to get the sitree for mi main menu (the one on top)

For that do I have to create another export function in Page.php and another ExportPage.ss something like Export2Page.ss ??

Thank you if you can help

Attached Files
Go to Top