|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
[1.6 bug] Using self/parent/parent for detecting where one is in the document hierarchyHi
If some functionality is needed based on where one is in the document hierarchy then using things like this mostly works: petal:condition="true: self/parent/parent; true: self/parent/parent/children" Or: petal:condition="false: self/parent/parent/equals ancestor;" But if a document doesn't exist when testing for a parent/parent (for example when a template designed for grandchild pages is used for child pages) then there is an internal server error rather than Petal returning false and things like this are written to the apache logs: [PETAL ERROR] Cannot find value for 'equals' at '/self/parent/parent': equals cannot be retrieved (current value was undef, near self/parent/parent/equals ancestor) at /usr/lib/perl5/site_perl/5.8.6/Petal/Hash/Var.pm line 125 Which is rather inconvient... Chris -- Chris Croome <chris@...> web design http://www.webarchitects.co.uk/ web content management http://mkdoc.com/ _______________________________________________ MKDoc-dev mailing list MKDoc-dev@... https://lists.webarch.co.uk/mailman/listinfo/mkdoc-dev |
|
|
Re: [1.6 bug] Using self/parent/parent for detecting where one is in the document hierarchy> [PETAL ERROR] Cannot find value for 'equals' at
> '/self/parent/parent': equals cannot be retrieved (current value > was undef, near self/parent/parent/equals ancestor) at > /usr/lib/perl5/site_perl/5.8.6/Petal/Hash/Var.pm line 125 If self/parent doesn't return a document, then calling a method on this non-object can't possibly work. Test for the existence of self/parent first: <h1 petal:condition="self/parent"> This document has a parent called <span petal:replace="self/parent/title">Mavis</span> </h1> <h1 petal:condition="self/parent; self/parent/parent"> This document has a grandparent called <span petal:replace="self/parent/parent/title">Betty</span> </h1> <h1 petal:condition="false: self/parent"> This document doesn't have a parent :-( </h1> <h1 petal:condition="self/parent; false: self/parent/parent"> This document doesn't have a grandparent :-( </h1> -- Bruno _______________________________________________ MKDoc-dev mailing list MKDoc-dev@... https://lists.webarch.co.uk/mailman/listinfo/mkdoc-dev |
|
|
Re: [1.6 bug] Using self/parent/parent for detecting where one is in the document hierarchyHi
On Fri 24-Feb-2006 at 12:48:23PM +0000, Bruno Postle wrote: > > Test for the existence of self/parent first: > > <h1 petal:condition="self/parent"> > This document has a parent called > <span petal:replace="self/parent/title">Mavis</span> > </h1> > > <h1 petal:condition="self/parent; self/parent/parent"> > This document has a grandparent called > <span petal:replace="self/parent/parent/title">Betty</span> > </h1> > > <h1 petal:condition="false: self/parent"> > This document doesn't have a parent :-( > </h1> > > <h1 petal:condition="self/parent; false: self/parent/parent"> > This document doesn't have a grandparent :-( > </h1> I know this should work but it doesn't seem to -- for example try this code in a document: <!--? document location test code --> <!--? root document --> <div petal:condition="false: self/parent;" > This document has no parent therefore it must be the front page. </div> <!--? child document --> <div petal:condition="true: self/parent; false: self/parent/parent;" > This document has a parent but no grand parent, therfore it must be a child of the front page document. </div> <!--? grandchild document --> <div petal:condition="true: self/parent/parent; false: self/parent/parent/parent;" > This document has a parent and a grand parent, therfore it must be a grandchild of the front page document. </div> <!--? great grandchild document --> <div petal:condition="true: self/parent/parent/parent; false: self/parent/parent/parent/parent;" > This document has a parent and a grand parent and a great grandparent, therefore it must be a great grandchild of the front page document. </div> <!--? great great grandchild document --> <div petal:condition="true: self/parent/parent/parent/parent; false: self/parent/parent/parent/parent/parent;" > This document has a parent and a grand parent and a great grandparent and a great great grandperent, therefore it must be a great great grandchild of the front page document. </div> I get a internal server error and this error in the logs when this is added to a template that is a child of the front page: [PETAL ERROR] Cannot find value for 'parent' at '/self/parent/parent': parent cannot be retrieved Chris -- Chris Croome <chris@...> web design http://www.webarchitects.co.uk/ web content management http://mkdoc.com/ _______________________________________________ MKDoc-dev mailing list MKDoc-dev@... https://lists.webarch.co.uk/mailman/listinfo/mkdoc-dev |
|
|
Re: [1.6 bug] Using self/parent/parent for detecting where one is in the document hierarchyChris Croome wrote:
> > I know this should work but it doesn't seem to -- for example try this > code in a document: Re-read my email. If an object or document possibly doesn't exist, you have to test for its existence before trying to access methods. This assumes that self/parent exists: <div petal:condition="true: self/parent/parent; false: self/parent/parent/parent;" > This code makes no assumptions: <div petal:condition="true: self/parent; true: self/parent/parent; false: self/parent/parent/parent;" > -- Bruno _______________________________________________ MKDoc-dev mailing list MKDoc-dev@... https://lists.webarch.co.uk/mailman/listinfo/mkdoc-dev |
| Free Forum Powered by Nabble | Forum Help |