# Input type: resource-id?

**URL:** <https://forum.modmore.com/t/input-type-resource-id/470>\
**Category:** ContentBlocks\
**Created:** [November 4, 2016, 11:01am UTC](https://forum.modmore.com/t/input-type-resource-id/470 "2016-11-04T11:01:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![UCnet](https://forum.modmore.com/letter_avatar_proxy/v4/letter/u/85f322/32.png) [@UCnet](https://forum.modmore.com/u/UCnet)\
**Post date:** [November 4, 2016, 11:01am UTC](https://forum.modmore.com/t/input-type-resource-id/470/1 "2016-11-04T11:01:54Z")

</div>

hi,

input-type ‘link’ does provide a _link_ to a resource, ok.  
but I want to get the _id_ of a resource (to provide it as a parameter to getResources).

cbGetField &returnAsJSON does return the id within .link-property,  
but cbGetField always returns the path instead of the id!

why does it not have [[~[[+link]]]] in template for the field instead of [[+link]] ?  
it would be much more flexible! (or even a value of [[+id]] would be fine!)

so my question:  
how do I let the user/editor choose a resource and return the id of this resource for further processing ?

it’s not an option to let the user/editor find the id (yes, it always shows in brackets in the resource-tree) and just enter that number!

TIA

Marc

---

<div class="post-metadata">

**Author:** ![isaacniebeling](https://forum.modmore.com/user_avatar/forum.modmore.com/isaacniebeling/32/118_2.png) [@isaacniebeling](https://forum.modmore.com/u/isaacniebeling)\
**Post date:** [November 4, 2016, 12:34pm UTC](https://forum.modmore.com/t/input-type-resource-id/470/2 "2016-11-04T12:34:45Z")

</div>

If you just want the ID, you can use the `[[+link_raw]]` placeholder. Here’s the documentation in the link input: [https://www.modmore.com/contentblocks/input-types/link/](https://www.modmore.com/contentblocks/input-types/link/)

Does that help?

---

<div class="post-metadata">

**Author:** ![UCnet](https://forum.modmore.com/letter_avatar_proxy/v4/letter/u/85f322/32.png) [@UCnet](https://forum.modmore.com/u/UCnet)\
**Post date:** [November 7, 2016, 11:24am UTC](https://forum.modmore.com/t/input-type-resource-id/470/3 "2016-11-07T11:24:11Z")

</div>

yes, that’s it. just the resource-id.

but regarding the documentation: “the link without protocols or link tag”, I didn’t expect it to be the ID.  
🕶

thanks a lot.

Marc

---

<div class="post-metadata">

**Author:** ![UCnet](https://forum.modmore.com/letter_avatar_proxy/v4/letter/u/85f322/32.png) [@UCnet](https://forum.modmore.com/u/UCnet)\
**Post date:** [November 7, 2016, 11:30am UTC](https://forum.modmore.com/t/input-type-resource-id/470/4 "2016-11-07T11:30:26Z")

</div>

BTW: my approach was a bit more complex

I wrote a snippet: [[\_cbGetLinkID? &field=`123`]]

```
<?php
$fld = $modx->getOption('field', $scriptProperties, 0, true);
$json = $modx->runSnippet('cbGetFieldContent',array('field' => $fld, 'returnAsJSON' => 1));
list($field) = json_decode($json); 
echo $field->link;
```

---

<div class="post-metadata">

**Author:** ![mhamstra](https://forum.modmore.com/user_avatar/forum.modmore.com/mhamstra/32/459_2.png) [@mhamstra](https://forum.modmore.com/u/mhamstra)\
**Post date:** [November 11, 2016, 1:38pm UTC](https://forum.modmore.com/t/input-type-resource-id/470/5 "2016-11-11T13:38:52Z")

</div>

`[[+link_raw]]` may also contain an email address or url if that’s what the user entered in the link field. That’s why `[[+link]]` returns the generated url instead of just the resource ID, as `[[+link]]` will always have a full url including protocols.

Alternative solutions could be to use the dropdown input in 1.5 or the third party [cbResourceSelect](https://github.com/degoya/cb.resourceSelectInput) input instead of a link.
