We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3177
    • 137 Posts
    Ok, I’ll go a bit deeper in the solution since there seems to be interest in it.

    There are two questions here:
    1) How do I generate those URLs
    2) What do I do in the Snippet.

    Re 1)
    We don’t want the url to be like www.mysite.nl/?product=lawnmower&type=yamaha&model=XV13
    since this is not good for Google ranking.
    A better url is www.mysite.nl/product/lawnmower/yamaha/xv13.html.
    An even beter url is
    www.mysite.nl/product/lawnmower/xv13/a-good-lawnmower-for-soccer-fields.html
    (To catch all those Google Searches: "what is the best lawnmower for soccer fields")

    The homepage is a simple page with a list of links to all products. Or 26 pages with
    product-starting-with-A, B, C, etc.
    Each product has a description, a productcode and a 5-word-elevatorpitch.

    Create a snippet going through you product database and generate a link
    for each product. If you have a lot of products, make that snippet cachable,
    you don’t want every visitor selecting the whole producttable from your DB smiley

    Together with some SEO-magic those specific product pages are ranked
    high in the results on searches on those specific products.

    Re 2)
    The snippet in the "Virtual Page" starts of with getting the $_SERVER["REQUEST_URI"].
    In that variable we find "/product/lawnmower/xv13/good-for-soccerfiels.html".
    The structure is "product/[[productname]]/[[producttype]]/[[google-stuff]]".
    PHP:
    	list($x, $productname, $producttype, $y) = split("/", $_SERVER["REQUEST_URI"], 4);
    


    Ignore the google-stuff and use the productname and producttype to go
    to the database and there you get all info on this product.
    DBQuery:
        select * 
        from producttable 
        where productname = '$productname' AND producttype = '$producttype'
    


    Does this make any sense the people who requested more info?


      • 16183
      • 1,390 Posts
      Bert,

      Thanks for the info...it does make sense. The rewrite rules for your "better urls", that’s all in your .htaccess file? Thx.

      cheers/k
        • 7155
        • 160 Posts
        Quote from: bertcatsburg at Sep 03, 2009, 03:43 PM

        Ok, I’ll go a bit deeper in the solution since there seems to be interest in it.

        There are two questions here:
        1) How do I generate those URLs
        2) What do I do in the Snippet.

        Re 1)
        We don’t want the url to be like www.mysite.nl/?product=lawnmower&type=yamaha&model=XV13
        since this is not good for Google ranking.
        A better url is www.mysite.nl/product/lawnmower/yamaha/xv13.html.
        An even beter url is
        www.mysite.nl/product/lawnmower/xv13/a-good-lawnmower-for-soccer-fields.html
        (To catch all those Google Searches: "what is the best lawnmower for soccer fields")

        The homepage is a simple page with a list of links to all products. Or 26 pages with
        product-starting-with-A, B, C, etc.
        Each product has a description, a productcode and a 5-word-elevatorpitch.

        Create a snippet going through you product database and generate a link
        for each product. If you have a lot of products, make that snippet cachable,
        you don’t want every visitor selecting the whole producttable from your DB smiley

        Together with some SEO-magic those specific product pages are ranked
        high in the results on searches on those specific products.

        Re 2)
        The snippet in the "Virtual Page" starts of with getting the $_SERVER["REQUEST_URI"].
        In that variable we find "/product/lawnmower/xv13/good-for-soccerfiels.html".
        The structure is "product/[[productname]]/[[producttype]]/[[google-stuff]]".
        PHP:
        	list($x, $productname, $producttype, $y) = split("/", $_SERVER["REQUEST_URI"], 4);
        


        Ignore the google-stuff and use the productname and producttype to go
        to the database and there you get all info on this product.
        DBQuery:
            select * 
            from producttable 
            where productname = '$productname' AND producttype = '$producttype'
        


        Does this make any sense the people who requested more info?

        brilliant!

        well explained

        thx
        when your website’s done, feel free to show it off
          • 2927
          • 2 Posts
          Hey all, new to modx here, like what I see so far. Developing a site with the same situation, we have several products and we are going about setting it up as suggested in this thread. My question is, is there an easy way the customer could access the database through modx to edit the properties of different products in table? Or is that something that would need to be custom made?
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            You would need a custom module for that. There are a few "module-builders" that set up a basic, generic CRUD database access module, but you would still need to customize it for your particular needs.

            http://modxcms.com/extras/package/280
            http://modxcms.com/extras/package/428
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 14267
              • 113 Posts
              Quote from: OpenGeek at Sep 02, 2009, 10:41 AM

              Take Ditto, etc. out of the equation. Those tools are for summarizing Resources (aka Documents), not custom database items. The whole point of externalizing database items is to create dynamic views (as Resources) including custom summarization views. Ditto would not apply, nor should it. IMO, Ditto is used way too much for solving problems beyond it’s intended purpose. And you can already link custom data to Resources via Template Variables and Plugins where necessary.

              Using Resources to represent custom data is plausible if you have a limited quantity of data; otherwise, I’d create dynamic views of custom data tables.
              Another consideration--I found existing Resources tools such as Ditto, getParent and @inherit useful in setting up a tree-type product catalog with categories, subcategories, including discounts, but that was a smaller catalog, not 1200 products.

              I think this discussion brings up something that I think a lot of folks would like to see--a set of tools to facilitate working with external data that provides at least some of the same types of functions and power that existing Resources tools have. Ditto may indeed be overused, but if so it’s because it’s really a pretty amazing tool, isn’t it?
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                The existing Ditto et al snippets are actally custom-built applications to specifically accomodate the MODx data structures, including internal arrays that the MODx parser has already built from data retrieved from its database.

                With external data structures, the tools would need to fit these external data structures. Every application would have different requirements, and the functioning of the tools would be totally dependent on the design of the database.

                Building a toolkit that says "You must represent your data in this manner and this manner only" not only limits those using it, but leads to the developers of the toolkit being inundated with feature-creep and modification requests because very few sites can be limited in that way. A set of tools that one site is able to use out-of-the-box will need extensive modification for 99+% of other would-be users.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 20413
                  • 2,877 Posts
                  What an awesome thread! Thanks bertcatsburg! cool

                  Talking about Ditto...
                  I use this: http://modxcms.com/forums/index.php/topic,37590.msg226859.html#msg226859
                  for my Reflect (blog) listings. It allows me to link like this:



                  • June, 2009, Day not defined, Pagination start-page
                    http:// my-url.com/archives-6-2009-0-0
                    instead of http:// my-url.com/blog-archives.html?wp_month=6&wp_year=2009&wp_day=false&wp_start=0

                  • August, 2009, 02, Pagination page 2 (if &display=`10`)
                    http:// my-url.com/archives-8-2009-02-10
                    instead of http:// my-url.com/blog-archives.html?wp_month=8&wp_year=2009&wp_day=02&wp_start=10
                    @hawproductions | http://mrhaw.com/

                    Infograph: MODX Advanced Install in 7 steps:
                    http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                    Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                    http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                    • 2927
                    • 2 Posts
                    You would need a custom module for that. There are a few "module-builders" that set up a basic, generic CRUD database access module, but you would still need to customize it for your particular needs.

                    http://modxcms.com/extras/package/280
                    http://modxcms.com/extras/package/428

                    Thanks, I’ll have to look into that.