We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21800
    • 174 Posts
    how is it possible to call only the [content] of a defined page [id] by an url?
    A mooTools script shall insert it into a certain place in annother page. I have the script so far, but it loads the whole page with header etc. int the div I’ve appointed.
    huh
      • 7923
      • 4,213 Posts
      Install getField snippet and make a document that uses blank template and runs a snippet that has this code in it:

      return $modx->runSnippet(’getField’, array(’docid’ => $_GET[’docid’], ’field’ => ’content’));

      Then you can get the content from some document using url: yoursite.tld/thepage.html?docid=23


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 21800
        • 174 Posts
        thanx, Doze
        that was it. Should be part of core installion, isn’t it? something like [[content, id=xx, id=xx, ...]] and page.html?tag=content or something like this ...
        (please forget about a former comment of mine, I misunderstood your suggestion first)

        Anyway it works fine with your call "yoursite.tld/thepage.html?docid=23" even with the syntax "[~50~]?docid=27".

        But
        if I put it into a js call like "<a href="javascript:getContent(’[~50~]?docid=27’);">Ajax Link</a>" the script works correctly but the output is a sql error:

        « MODx Parse Error »
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’html) AND sc.published=1 AND sc.deleted=0 ) AND (sc.privatew’ at line 3 »
        SQL: SELECT DISTINCT sc.parent FROM `usr_web325_1`.`ion_site_content` sc LEFT JOIN `usr_web325_1`.`ion_document_groups` dg on dg.document = sc.id WHERE (sc.id IN (27.html) AND sc.published=1 AND sc.deleted=0 ) AND (sc.privateweb=0) GROUP BY sc.id LIMIT 1

        What can I do about that?
          • 33372
          • 1,611 Posts
          I would check out your getContent javascript, because on first glance it appears to be appending .html to your docid (either on its own or in conjuction with MODx’s URL rewriting) and thus crashing the SQL query.
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 21800
            • 174 Posts
            Exactly that was the point. I had to modify the call of the script I implemented a couple of days before, thanx ZAP. Looking foreward to some free time around Easter.