VirtualPage picking Layout/Page.ss templates regardles of real Page Type

60 views
Skip to first unread message

Tobias Oetiker

unread,
Mar 6, 2016, 12:48:33 PM3/6/16
to silverst...@googlegroups.com
Hi

I am using VirtualPages extensively in our website. With
upgrading to 3.3 I found that they are now all rendering their
pages using the Page.ss layout ... instead of the Layout
corresponding to the page they are pointing to.

I was able to 'fix' the problem for now with this ugly ugly patch:

diff --git a/code/controllers/ContentController.php b/code/controllers/ContentController.php
index 944ce5e..5952a3b 100755
--- a/code/controllers/ContentController.php
+++ b/code/controllers/ContentController.php
@@ -385,6 +385,14 @@ HTML;
SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SiteTree"),
SSViewer::get_templates_by_class(get_class($this), "", "Controller")
);
+ echo "<!--";
+ var_dump($templates);
+ echo "-->";
+ # compensate for Page being the first option returned by VirtualPages
+ # ... this is rather ugly
+ if ($templates[0] == 'Page'){
+ array_shift($templates);
+ }

return new SSViewer($templates);
}

While normal pages get the Page Class name as the first item listed
in $templates, VirtualPages get 'Page' as the first option and if
there is layout called Page.ss it will be picked up.

I guess I am doing something badly wrong here since I can not find
anyone else reporting this ... but what?

cheers
tobi

--
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
www.oetiker.ch to...@oetiker.ch +41 62 775 9902

Tobias Oetiker

unread,
Mar 7, 2016, 6:10:53 AM3/7/16
to silverst...@googlegroups.com
Hi Gregory,

on the pilgrimage website

https://www.jakobsweg.ch/de/eu/ch/weg/rankweil-st-peterzell/urnaesch-peterzell/

there is a section "Unterkünfte"

the items in there are pages for Locations with Hotels and B&Bs and
such ...

a single Location may appear in several tracks ... we use
VirtualPages to link them in ...

We use VirtualPages and not redirects, since we want the user to
remain 'in tree' as they navigate (bread crums corrct and all)

the behaviour changed somewhere between 3.1 and 3.3 ...

it was working fine before.

cheers
tobi



Today Gregory Smirnov wrote:

> Hello Tobias,
>
> How do you use Virtual Pages?
> I guess, the reason there are no issue created because little who is using this feature. I might be wrong though.
> We always create different page types to represent different layout in our sites.
> I would really like to learn when and how virtual pages might be used.
>
> Thank you,
> Gregory
> --
> You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
> To post to this group, send email to silverst...@googlegroups.com.
> Visit this group at https://groups.google.com/group/silverstripe-dev.
> For more options, visit https://groups.google.com/d/optout.

Loz Calver

unread,
Mar 7, 2016, 11:46:06 AM3/7/16
to SilverStripe Core Development
Hi Tobias,

Looks like there’s an open issue on Github for what you’re describing: https://github.com/silverstripe/silverstripe-cms/issues/1336.

Cheers,
Loz

Tobias Oetiker

unread,
Mar 7, 2016, 12:16:12 PM3/7/16
to Loz Calver, SilverStripe Core Development
Today Loz Calver wrote:

> Hi Tobias,
>
> Looks like there’s an open issue on Github for what you’re
> describing: https://github.com/silverstripe/silverstripe-cms/issues/1336.

Hi Loz,

exactly this is the problem ...

thanks! for pointing this out.

cheers
tobi
> > www.oetiker.ch to...@oetiker.ch <javascript:> +41 62 775 9902
Reply all
Reply to author
Forward
0 new messages