For those looking for another way to get to the ID of a SymLink itself, I wrote a snippet that does it. This will have been a problem for almost no-one since version 2.0.5-pl when SymLinks were changed to 'overlay' their details on the Target. I found myself in a specific situation though.
I wanted to set the System Setting 'symlink_merge_fields' to 'No' because it made everything a lot simpler in terms of guaranteeing nothing was overwritten with content drawn from the SymLink. I could list all the exceptions (being every single field in a TV rich template), but then if I ever added another field and forgot to add it to that list, strange behaviour may start to creep in.
I wanted the SymLink be IDENTICAL to the Target with the only difference being a correct bread crumb based on the location of the SymLink or Target in the structure. Hence I needed the SymLink ID to bait the BreadCrumb extra properly.
Big thanks to opengeek who supplied the building blocks of this snippet code in a few different places in the forums. The following placed into a snippet will correctly return the ID of the current resource if you have Friendly URLs switched on.
<?php
$uri = $_GET[$modx->getOption('request_param_alias')];
$resourceId = 0;
if (array_key_exists($uri, $modx->aliasMap)) {
$resourceId = $modx->aliasMap[$uri];
};
return $resourceId;
If you're not using friendly URLs, try switching $_GET[$modx->getOption('request_param_alias')] for $_GET['q'] (untested but may work based on comments I've seen).
MODX - so many ways to achieve any given thing. Love it!
[ed. note: jcdm last edited this post 10 years, 8 months ago.]