We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36461
    • 102 Posts
    Hello,

    I need something like tv, but with a functionality of a chunk.

    I plan to make only resources available to user.

    So here is the problem - there will be a news section on every page, normally I would create a chunk and change news info from within a chunk, but since user won't have access to chunks this solution doesn't work. I could create a TV but user would have to change TV manually in each page.

    I hope I made myself clear.

    What could be the best option here ?

    I found this http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks, but I think it's slightly different.

    There probably is something similar in forum, but I wasn't sure which keyword to use.

    [ed. note: viltnieks last edited this post 15 years ago.]
      • 32316
      • 387 Posts
      whistlemaker Reply #2, 15 years ago
      I assume that you mean that by user you mean someone updating the site
      I plan to make only resources available to user.
      so it needs to be a resource!

      Then just use getResources or getResourceField call in your template - no TVs involved
      or create a TV that adds a getResourceField call to a page - if you want to have a choice to include or not include the news item on any particular page.
        • 13218
        • 134 Posts
        If i understand correctly, your setup is this:
        you have one chunk, maybe called "News_Chunk", that contains the news (probably in html)
        this chunk is used in every page
        but your backendusers can't access this chunk for editing

        If this is the way you want to do it, you could use a resource instead of that chunk:
        create a resource called "News". Hide it from menues and unpublish it, so it does not appear anywhere else.
        Then you enter the data, that usually goes into your chunk into the content-field of your resource.

        Then, instead of calling your chunk like
        [[$News_Chunk]]

        you use a simple snippet like this:

        create snippet "getNews"
        $rid = $modx->getOption('rid', $scriptProperties, false);
        if( !$rid ) return '';
        if( !$r = $modx->getObject('modResource', $rid) ) return '';
        return $r->content;


        Call it like so:
        [[getNews? &rid=`23`]]

        where rid is the id of your News resource.


        There are of course other, more flexible ways to integrate news, but if this works for you that's fine.
          @itWilllBeOK
          • 36461
          • 102 Posts
          Thank you, both of these methods will come in very handy in this and future use smiley