• Retrieve ID of a modSymLink#

  • sushi Reply #1, 1 year, 8 months ago

    Reply
    Hi all,

    When viewing a resource of type modSymLink, the returns the ID of the original resource (as you would expect).

    Is it possible to retrieve the ID of the modSymLink itself?

    Thanks!


  • opengeek Reply #2, 1 year, 8 months ago

    Reply
    Quote from: sushi at Sep 22, 2010, 09:11 AM
    When viewing a resource of type modSymLink, the returns the ID of the original resource (as you would expect).

    Is it possible to retrieve the ID of the modSymLink itself?
    At the current time there is not a way to do this (that I can think of). I would love to hear ideas on how to achieve this before implementing a specific approach. Would you care to enter a ticket for this and maybe we can get some proposals and find the best way to accomplish this in a future release.


  • sushi Reply #3, 1 year, 8 months ago

    Reply
    Issue created: http://bugs.modx.com/browse/MODX-2355

    (I hope I did that right!)


  • paulk Reply #4, 1 year ago

    Reply
    The method I am using is a snippet called "getSymlinkId"

    the code is below

    $id= $modx->resource->get('id');

    $c = $modx->newQuery('modResource');
    $c->select('content');
    $c->where(array('id'=>$id));
    $c->prepare();
    $c->stmt->execute();
    $symlinkId = $c->stmt->fetchColumn();
    $c->stmt->closeCursor();

    if(is_numeric($symlinkId) && !empty($symlinkId))
    {
    return intval($symlinkId);
    }

    This may help, I think it still needs a bit of work, but it does return the symlink Id