-
☆ A M B ☆
- 24,524 Posts
Do you mean the resource that the symlink is taken from?
-
☆ A M B ☆
- 24,524 Posts
Hm. Have been doing some experimenting with symlinks. They behave rather oddly. I had expected that just the content field from the resource linked to would be inserted. The content of the symlink in the database is the ID you're linking to, but it's proving very difficult to get at that value.
-
☆ A M B ☆
- 24,524 Posts
Sometimes the pagetitle, longtitle, description, introtext will be the same as the resource being linked to, sometimes it will be that of the symlink resource. Having the various tags uncached seems to help.
A snippet to get the class_key always returns modDocument, even though it's obviously a modSymLink. A snippet to get the content directly from the database will return the linked resource's content.
$content = $modx->resource->get('content');
-
☆ A M B ☆
- 24,524 Posts
I can get the actual content (the ID of the linked resource) using @SELECT binding for a TV - but only if I specify the actual ID of the symlink:
@SELECT content from modx_site_content where id = 4
So you could use such a TV but it would have to be edited for each symlink to use its own ID. [[*id]] didn't work there at all, nor did a snippet to get the ID.
-
☆ A M B ☆
- 24,524 Posts
Got it! Use a snippet:
$thisId = $modx->resource->get('id');
$result = $modx->query("SELECT * FROM modx_site_content WHERE id=$thisId");
if (!is_object($result)) {
return 'No result!';
}
else {
$row = $result->fetch(PDO::FETCH_ASSOC);
return 'Result:' . $row['content'];
}
return;
the raw xPDO query doesn't process symlink content the way that the modResource object does.
http://rtfm.modx.com/display/xPDO20/xPDO.query