cpe
Elite Observer

Get GID of PageRef

Jump to solution

Dear Community,

I want to display the GID of the PageRef.

I found how to get the GID of the Page and that works fine:
https://docs.e-spirit.com/odfs/template-develo/rules/form-properties/property-gid/index.html

I need the same, but with "#this" instead of "#global", I think, but "#this" is not available in the rules.

If I put $CMS_VALUE(#this.gid)$ into the HTML-template, I get nothing. Same for #global.gid actually.

If I were using the API, I could get me an GidAgent, but I am not.
https://docs.e-spirit.com/odfs/access/de/espirit/firstspirit/common/GidAgent.html#getGid(de.espirit....

I know where to find the GID of a PageRef in the SiteArchitect, but my customer mainly works with the Content Creator and I need it shown there.

Has anyone got another idea for me?

Thanks in advance and cheers!
Connz

0 Kudos
1 Solution

Accepted Solutions
hoebbel
Crownpeak employee

Hi Connz,

you can use the GidAgent within the template code, too.

$CMS_SET(gidAgent,#global.requireSpecialist(class("de.espirit.firstspirit.common.GidAgent").TYPE))$
GID: $CMS_VALUE(gidAgent.getGid(#global.node))$

Best regards
Holger

View solution in original post

4 Replies
hoebbel
Crownpeak employee

Hi Connz,

you can use the GidAgent within the template code, too.

$CMS_SET(gidAgent,#global.requireSpecialist(class("de.espirit.firstspirit.common.GidAgent").TYPE))$
GID: $CMS_VALUE(gidAgent.getGid(#global.node))$

Best regards
Holger

cpe
Elite Observer

Hey Holger,

thanks! That is great! I did not know, I could do that! 😄

But there is no way to get that into the content form for the template, is there?

Cheers
Connz

0 Kudos
hoebbel
Crownpeak employee

Hello Connz,

the GID of the page is just a breeze

<RULE when="ONLOCK">
	<WITH>
		<PROPERTY name="GID" source="#global"/>
	</WITH>
	<DO>
		<PROPERTY name="VALUE" source="name_of_entry_component"/>
	</DO>
</RULE>

The GID of the pageref (and if there are more than one, which one?) is a different level. A good solution could be a value service that fetches the information (and takes into account that there may be none, one or many page references) and then writes it to an input component (executed once onlock or onsave)
Another solution might be a script that writes the information (regularly as a schedule entry, during the preview, via an EventListener when saving, ...). However, this solution will often encounter locked IDProviders (since it doesn't use the session of the editor)

Best regards
Holger

0 Kudos

Hey Holger,

yes, that was my first attempt as I also assumed I just needed the GID of the page. Such a nice solution! But I indeed need the GID of the PageRef.

Good point about there not being a 1-to-1 of Page to PageRef and the consequences of that. So far I have not seen projects that really make use of that in their daily doing, but it could be done of course.

I think I will stick with my little script for now.

Thanks for the input! 🙂

Cheers
Connz

0 Kudos