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

    I’ve been fiddling arround with some settings and resources in MODx for the better part of a day now and I’ve almost completed what I set out to do. Pretty awesome considering I didn’t knew much about MODx when I started out.

    Anyway, to get to my real question:

    I’ve got a simple blog and website setup. Your avarage basic frontpage/home, a news with sections and categories, same for the blog and some other pages like profile, about and links. All well and good, but I stumbled onto a problem this afternoon. I’ve created a complete rundown of all the blogs with getResources. The snipper itself ignores all containers and so fetches all the posts/resources. Simply bloody awesome - seriously.

    Now, of course, I can use the &tpl= variable to choose my layout which would be a chunk, obviously. This, too, worked like a charm, but now comes the fun part. When I directly go to the article/resource/post via a permalink I created (/section/category/resource-alias.html) my design is totally gone. Don’t get me wrong, the template I set up with the [[*content]] variable works perfectly, but it does not use the blogItem chunk (that’s how I named it, also used in getResources’ &tpl). Now, with MODx being a complete bitch with all it’s possibilities (this is a massive pro, not a con), I need a decent way to set it up. So, what do I do?

    1. Create different templates in the Templates attrib in the menu (for frontpage, blogitem, post, contact stuff like that)
    2. Create a chunk for the header, footer, menu and breadcrumbs, then use a template to only include the blogItem layout and of course the [[$siteHeader/Footer]]

    Those are all the possibilities as I see them right now, but almost certainly I am missing like... 20 other options! tongue

    Oh yea, to give you a better idea of what I am talking about, here my menu tree. It’s all Dutch but that shouldn’t be a problem for you guys, as the idea is pretty the same.


    Thanks a bunch guys!
      @MarkGHErnst

      Developer at Adwise Internetmarketing, the Netherlands.
      • 3749
      • 24,544 Posts
      Congratulation on you progress so far. That’s really impressive for someone new to MODx.

      You’re right that there are lots of ways to do this involving snippets, Tpl chunks, PHX conditionals, and Template Variables.

      It’s really a matter of personal preference. Some people like to minimize the number of templates used, while others like to have a different template for each page type.

      I’m sure others with more blog experience will have more concrete suggestions.

      Welcome to MODx. smiley
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 24865
        • 289 Posts
        Quote from: BobRay at Jul 29, 2010, 03:47 AM

        Congratulation on you progress so far. That’s really impressive for someone new to MODx.

        You’re right that there are lots of ways to do this involving snippets, Tpl chunks, PHX conditionals, and Template Variables.

        It’s really a matter of personal preference. Some people like to minimize the number of templates used, while others like to have a different template for each page type.

        I’m sure others with more blog experience will have more concrete suggestions.

        Welcome to MODx. smiley
        Thanks man, I’m looking forward to creating websites for my clients. I’m a pretty experienced when it comes down to Joomla and custom CMSes, but this is a whole different cake. No more components and modules, just chunks and snippets with custom components and so forth. Simply awesome. I’ve also been fiddling around with the TV to make tags and I must admit - Wow.

        Looking forward to hearing some more tips on how to resolve my issue!
          @MarkGHErnst

          Developer at Adwise Internetmarketing, the Netherlands.
          • 4172
          • 5,888 Posts
          if you want to have the same layout on your blog-item-page as on your items in your blog-page you have one prob.

          in your chunk blogitems you have to use placeholder-tags [[+yourfieldname]]
          now when you place your chunk [[$blogitem]] to your template this will not work, because modx parses the fields from your resource into placeholders with tags like that: [[*yourfieldname]].
          What you need in your template, if you want to use the same chunk, is a snippet which replaces your placeholders in your chunk your resource now.
          Ditto had the parameter &documents, which getResources doesn’t. Perhaps you can try it with Ditto like that:

          [[Ditto? &documents=`[[*id]]` &tpl=`blogitem`]]


          its perhaps a bit overkill, but this did it in evo. Perhaps we have to create a little snippet which can do the same (get resource and TVs and replace a chunks placeholders with them)

          or try to call your chunk with parameters :
          [[$blogitem? &tv1=`[[*tv1]]` &tv2=`[[*tv2]]`]]


            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 24865
            • 289 Posts
            Quote from: Bruno17 at Jul 29, 2010, 04:46 AM

            if you want to have the same layout on your blog-item-page as on your items in your blog-page you have one prob.

            in your chunk blogitems you have to use placeholder-tags [[+yourfieldname]]
            now when you place your chunk [[$blogitem]] to your template this will not work, because modx parses the fields from your resource into placeholders with tags like that: [[*yourfieldname]].
            What you need in your template, if you want to use the same chunk, is a snippet which replaces your placeholders in your chunk your resource now.
            Ditto had the parameter &documents, which getResources doesn’t. Perhaps you can try it with Ditto like that:

            [[Ditto? &documents=`[[*id]]` &tpl=`blogitem`]]


            its perhaps a bit overkill, but this did it in evo. Perhaps we have to create a little snippet which can do the same (get resource and TVs and replace a chunks placeholders with them)

            or try to call your chunk with parameters (didn’t try that, yet):
            [[$blogitem? &tv1=`[[*tv1]]` &tv2=`[[*tv2]]`]]




            Looking at your Ditto solution, that’s exactly what I just did! Hehe. Although, I created my own Snippet that fetches the resource and renders it as a chunk. Of course, this is a work-in-progress snippet but I think you guys get the basic idea.

            <?php
            	if (!isset($scriptProperties['id'])) {
            		exit('Im sorry? I need an ID to work with');
            	}
            	
            	$resource = $modx->getObject('modResource', array('id' => $scriptProperties['id']));
            		
            	return $modx->parseChunk('newsItem', $resource->toArray());
            ?>


            Thanks for your solution in any case! I think I might try that as well... And I must say, I did not know you could use parameters on a chunk as well!
              @MarkGHErnst

              Developer at Adwise Internetmarketing, the Netherlands.
              • 3749
              • 24,544 Posts
              Thanks for your solution in any case! I think I might try that as well... And I must say, I did not know you could use parameters on a chunk as well!

              Yup. Any parameter values sent in a chunk tag will be available as placeholders in the chunk, accessible with [[+paramName]].
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 24865
                • 289 Posts
                Awesome. In that case, how far does MODx go with thinks like multidimensional arrays? I know that there is TV that can be used like so:
                [[*user.user_id]]

                Or something like that...
                  @MarkGHErnst

                  Developer at Adwise Internetmarketing, the Netherlands.
                  • 3749
                  • 24,544 Posts
                  Dots in modx identifiers can be confusing. Sometimes, they’re just part of the name -- prefixes used to prevent collisions. Personally, I think hyphens or underscores should have been used in that case, but that ship has sailed. I’m not sure about your multimensional array question. That’s one for OpenGeek.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting