[Helma-user] _extends & _prototype
Jonathan Puckey
me at jonathanpuckey.com
Thu Nov 2 19:51:36 CET 2006
Hi Michi,
Great, I get it now. I had seen the Mgr prototype idea mentioned
before, but I never understood the idea behind it. Very handy.
Thanks alot!
I do have a little follow-up question:
How do I now go about making the href() function create the right url
for the pages depending on which collection they are in?
i.e. when I'm in the archive, I want to link to pages as /category-
title/archive/2006/page-title/
and when I'm in a category I want to link to pages as '/category-
title/page-title/
I've tried:
_parent = cat, cat.archive
But it always uses the first one as the href (when I put
'cat.archive' as the first, it just always renders te hrefs to that)
I've considered just hacking this by creating the hrefs myself with
string concatenation, but I would really like to try to keep doing
this the Helma way..
grts-
Jonathan
type.properties files for reference:
Category type.properties:
_db = myDataSource
_table = CATEGORY
_id = ID
_parent = root
_children = collection(Page)
_children.local = ID
_children.foreign = PAGE_CAT
_children.accessname = URLTITLE
archive = collection(Page)
archive.group = YEAR
archive.local = ID
archive.foreign = PAGE_CAT
archive.accessname = URLTITLE
archive.group.prototype= ArchiveMgr
archive.group.order = YEAR desc
Page type.properties:
_db = myDataSource
_table = PAGE
_id = ID
_parent = cat, cat.archive
cat=object(Category)
cat.local=PAGE_CAT
cat.foreign=ID
> Jonathan Puckey schrieb:
>> Ack.. This isn't working in the way I wanted it to after all..
>> When I restart my app and point to /Exhibitions/archive/2005/this-is-
>> the-title/, it uses the Page prototype and not the ArchivePage
>> prototype..
>> And then sometimes it does use the right one.. Flakey at best!
>>
>> So I need a different approach, I guess..
>>
> yes, using the inheritance-mechanism doesnt help you at all in your
> situation, since you are dealing with the same object. no matter
> how you
> access it via your URL.
>> What would be the best way to have the main.hac that is fired be
>> dependent on the collection that it resides in?
>>
> lets assume 'archive' is a Prototype named 'ArchiveMgr'. Then you
> could
> do the following:
> function main_action() {
> if (path.ArchiveMgr) {
> ... // we accessed the Page via the archive
> } else {
> ... // we accessed the Page directly
> }
> }
>
> hth,
> michi
>
> _______________________________________________
> Helma-user mailing list
> Helma-user at helma.org
> http://helma.org/mailman/listinfo/helma-user
>
> !DSPAM:4549ae74112961887183730!
>
More information about the Helma-user
mailing list