nommensen
I'm new here

unique id in genric link output

Hello,

new to FS and need to know how to get a unique id in the html output of a link which is rendered via a generic link template and used in DOM-Editor and Linklist.

This works in a linklist, but is deprecated:

$CMS_SET(set_lt_id,#global.id.toString()+"_"+ #link.getAttributes().get("localId").toString())$

Thanks in advance

Thomas

0 Kudos
15 Replies
feddersen
Community Manager

What type of link are you using? Internal/External or a generic link?

What FirstSpirit Version are you using?

0 Kudos

Zitat: "rendered via a generic link template and used in DOM-Editor and Linklist."

Damit meinte ich, dass ich eine generischen Verweisvorlage verwende.

Version: 4.2.219.38784

Danke

p.S.: Aktuell helfe ich mir mit einem Zähler, der pro Lin hochgesetzt wir und so eine eindeutige ID pro Seite darstellt. Scheint mir aber sehr unpraktisch, zumal es ja mit den Vorversionen von FS möglich war IDs pro Link abzufragen.

0 Kudos

Within a generic link, you can access the component "localId" like this: $CMS_VALUE(localId)$.

So this should work:

$CMS_SET(set_lt_id,#global.id.toString()+"_"+ localId.toString())$

0 Kudos

Hello Thomas,

or do you just want to use the id of the target node?

This would be (assumed, that the link is set by the component "sitestoreref"):

$CMS_VALUE(ref(sitestoreref).target.id)$

or in your example something like this:

$CMS_SET(set_lt_id,#global.id.toString()+"_"+ ref(sitestoreref).target.id.toString())$

Best regards,

  Holger

0 Kudos

Thanks for reply.

Unfortunately this does not work.  $CMS_VALUE(localId)$ used in a genric link generates no output.

And it does not work for external links either.

0 Kudos

Thomas Nommensen schrieb:

Thanks for reply.

Unfortunately this does not work.  $CMS_VALUE(localId)$ used in a genric link generates no output.

Can you post the form of your generic link, please?

0 Kudos

Thanks Holger. But if you have two links connected to the same target, you'll get the same ID, won't you?

I need a unique ID per page.

0 Kudos

Are two links to the same page within the same section allowed?

If not, you could use:

$CMS_SET(set_lt_id,#global.section.id.toString()+"_"+ ref(sitestoreref).target.id.toString())$

If they are not allowed within the same component, you could add a constant for each component

$CMS_SET(set_lt_id,"0" + #global.section.id.toString()+"_"+ ref(sitestoreref).target.id.toString())$

$CMS_SET(set_lt_id,"1" + #global.section.id.toString()+"_"+ ref(sitestoreref).target.id.toString())$

...

0 Kudos

Here is a simple form for an internal link. The form for the external one uses a normal CMS_INPUT_TEXT for the URL

<CMS_MODULE>

  <CMS_INPUT_TEXT name="lt_text" useLanguages="no">

    <LANGINFOS>

      <LANGINFO lang="*" label="Bezeichner"/>

    </LANGINFOS>

  </CMS_INPUT_TEXT>

  <FS_REFERENCE name="lt_link" useLanguages="no">

    <FILTER>

      <ALLOW type="pageref"/>

    </FILTER>

    <LANGINFOS>

      <LANGINFO lang="*" label="Page reference"/>

    </LANGINFOS>

    <PROJECTS>

      <LOCAL name=".">

        <SOURCES>

          <FOLDER name="root" store="sitestore"/>

        </SOURCES>

      </LOCAL>

    </PROJECTS>

  </FS_REFERENCE>

</CMS_MODULE>

0 Kudos