Get Page ID with render tags?

311 views
Skip to first unread message

rwagner

unread,
Nov 5, 2009, 4:29:36 PM11/5/09
to RedDot CMS Users
I'm trying to get the ID of the page with render tags. Not the GUID,
mind you, but the numeric ID of the page that you see in the page info
and use in searches. It seems too simple an attribute for it to *not*
be available in a render tag, but I can't for the life of me figure it
out. Info elements and RQL are not an option for what I have in mind.
So...does anyone have a clue to this?

(If this turns out to be super simple, I am prepared to be regarded as
a moron.)

-rw

markus giesen

unread,
Nov 5, 2009, 11:32:07 PM11/5/09
to RedDot CMS Users
Did you try to add an info element to each target page and then read
the value out with render tags as described here:
http://bit.ly/1EU3AP

I know you said: no info elements but this doesn't require an info
element in your render spot just its name and no list block mark.

cheers.

Stefan Buchali

unread,
Nov 6, 2009, 5:37:15 AM11/6/09
to RedDot CMS Users
As far as I know, it's impossible to get the page ID via render
tags. :-(
only the guid (which is called id in render tag syntax, just to
complete the confusion)

rwagner

unread,
Nov 9, 2009, 2:56:16 PM11/9/09
to RedDot CMS Users

Unfortunately you can't get info elements with render tags -- or at
least I've never seen it -- otherwise that would definitely serve my
needs. I've got a hack right now where I basically parse the HTML and
get the Page ID from the comment that RedDot puts on every page. It
works, but I would still like a more durable solution.

rwagner

unread,
Nov 16, 2009, 5:33:59 PM11/16/09
to RedDot CMS Users

I got a couple of requests for this, so I figured I'd just post it.
It's kind of a hack, but if all you need to do is display the Page ID
to your SmartEdit contributors without using a RedDot info element,
JavaScript can do the trick. I happen to be using the jQuery library
in "no conflict" mode, but I'm sure you can adapt this to whatever
suits your needs.

var pageid = jQuery.trim( jQuery("head").html().split("-- PageID")
[1].split("-")[0] );

I'm sure you could do this with a regex, but I'm lousy at them. Once
you have the page id in a variable you can display it however you
want.

Btw, the "trim" method is custom. Just Google "JavaScript trim" and
you'll find about 8 ways to do it.

Good luck!

On Nov 9, 2:56 pm, rwagner <wagner....@gmail.com> wrote:
> Unfortunately you can'tgetinfo elements with render tags -- or at
> least I've never seen it -- otherwise that would definitely serve my
> needs.  I've got a hack right now where I basically parse the HTML andgetthePageIDfrom the comment that RedDot puts on everypage.  It
> works, but I would still like a more durable solution.
>
> On Nov 6, 5:37 am, Stefan Buchali <stefan.buch...@gmail.com> wrote:
>
>
>
> > As far as I know, it's impossible togetthepageIDvia render
> > tags. :-(
> > only the guid (which is calledidin render tag syntax, just to
> > complete the confusion)

ArryD

unread,
Nov 18, 2009, 5:04:00 AM11/18/09
to RedDot CMS Users
I guess another way of looking at this is automatically setting the ID
value to a standard field element using RQL before using your render
tag code. That way you can then use the value from the standard field
element within your render tags.

markus giesen

unread,
Nov 18, 2009, 6:26:07 PM11/18/09
to RedDot CMS Users
I like ArryD's thinking. The ID never changes and therefore it's best
to store it in a stf_element - yay!

rwagner

unread,
Nov 23, 2009, 1:36:24 PM11/23/09
to RedDot CMS Users

I've gotten into trouble before with setting "required" fields with
RQL...but you're right that the Page ID never changes. Maybe that's a
low enough risk. There's just that nasty business of having to trigger
the RQL before being able to use the Page ID. But once you've got it,
you never have to run the RQL for that page again, which is nice.

So it sounds like we've found two possible solutions depending on the
need:

1) use JavaScript to fetch the Page ID from the comment in the HTML
markup
2) use RQL to get the Page ID and set an stf element.

Go team!
Reply all
Reply to author
Forward
0 new messages