We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51376
    • 2 Posts
    I have a written a plugin that is going to set a tv to a resource's event start date (a TV set by users) if it has one but if not set it to the published date.
    I've got two problems that might be related.

    The first is that I can use getTVValue to get my event start date but only if I use it's id rather than name. i.e.

    This works
    $evntStart = $resource->getTVValue(10);


    But this doesn't
    $evntStart = $resource->getTVValue('timelineStartDate');



    The second issue is I can't seem to get publishedon. This is probably related as I'm also trying to get it by its name. I can live with using ids if anyone can tell me the id of publishedon.
    This doesn't get anything...
    $publishedon = $resource->getTVValue('publishedon');



    I have the plugin set to OnDocFormSave.

    Been banging my head against the wall with this so hope someone can help.
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      publishedon is not a TV, it's a resource field. You can access that with:
      $resource->get('publishedon')


      I'm not sure why it wouldn't allow you to get the TV value by its name - I've definitely done that plenty of times without issue... are you sure it has a value, and that there are no typos in the name?
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 51376
        • 2 Posts
        Amazing thank you, that sorted the published on problem.

        For the name part, yes it has a value as I can get it when I use the id, and yes checked for typos (copy and pasted the name). It is a mystery I can live without knowing though.

        Thanks again and thanks for helping so quickly