We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8740
    • 36 Posts
    I’m using path aliasing and that’s working fine..
    But I’m trying to make a new folder with the module I’m developing and the folder and the content page show up fine in the manager - but I can’t browse the folder. I checked it against the db to make sure the folder matches up to a folder that was created in the manager and I’m not seeing anything different (besides the date and times). Is there some other table besides site_content I should be looking at?
      • 27376
      • 576 Posts
      Here’s a couple things you can try out:

      • Make a link to the folder in another of your documents by using [tt]<a href="[~x~]">[/tt] where ’x’ is the ID of the folder (found in the manager tree in ’()’).
      • Make sure that you’re typing the prefix & suffixes correctly when typing the URL directly in to your browser.
      • Type the ID directly in to your browser like so: [tt]http://www.example.com/index.php?id=x[/tt] where ’x’ is the ID of the folder.
      Without more information, this is all the help I can give. If you still have trouble, show us what you’re typing, what it should look like, and maybe a screenshot of what your manager window looks like.

      Enjoy!
        • 8740
        • 36 Posts
        I’ll have to reset it up to do a screen cap which I don’t think will help since the dynamically created container folder looks just like the one made by hand. The only difference is that I can’t access it from the front end

        i.e.: http://whaterver.com/news_and_articles/my_subject/1/my_article.php

        I can get http://whaterver.com/news_and_articles/my_subject/

        but not
        http://whaterver.com/news_and_articles/my_subject/1/
        or
        http://whaterver.com/news_and_articles/my_subject/1/my_article.php


        I’ve even gone back in to the db to change the alias’s to make sure they were in place and still nothing.

        I had to edit and save the container folder in the manager.....



        But here’s the code I’m running to create the folders..

        <br />    if(!$err)<br />     {<br />      // Get the current time <br />      $ts  = time();<br />      <br />      // Get the default template ID.<br />      $tpl = $modx->config[’default_template’];<br />    <br />      // Create an article record<br />      $sql = ’INSERT INTO `’.$modx->db->config[’table_prefix’].’news_articles` (`id`) VALUES (\’\’)’;<br />      $qry = $modx->db->query($sql);<br />      $aid = $modx->db->getInsertId();<br />      <br />      // Create the sub folder (id) of article<br />      $sql = ’INSERT INTO `’.$modx->db->config[’table_prefix’].’site_content`<br />              (`type`, `contentType`, `pagetitle`, `published`, `pub_date`, `parent`, `richtext`, `template`, `searchable`, `cacheable`,<br />               `createdby`, `createdon`, `editedby`, `editedon`, `publishedon`, `publishedby`, `alias`, `isfolder`)<br />               VALUES<br />              (\’document\’, \’text/html\’, \’’.$aid.’\’, \’1\’, \’’.$ts.’\’, \’’.$modx->db->escape($_POST[’category’]).’\’,<br />               \’1\’, \’’.$tpl.’\’, \’0\’, \’0\’, \’’.$modx->getLoginUserID().’\’, \’’.$ts.’\’, <br />               \’’.$modx->getLoginUserID().’\’, \’’.$ts.’\’, \’’.$ts.’\’, \’’.$modx->getLoginUserID().’\’, \’’.$aid.’\’, \’1\’)’;<br /><br />      $modx->db->query($sql);<br />      <br />      $pid = $modx->db->getInsertId();  <br />      <br />      // Front page only item?<br />      if(empty($_POST[’fullarticle’]))<br />       {<br />        $fp_only = 1;<br />            <br />        $sql = ’INSERT INTO `’.$modx->db->config[’table_prefix’].’site_content`<br />                (`type`, `contentType`, `pagetitle`, `published`, `pub_date`, `parent`, `content`, `richtext`, `template`, `searchable`, `cacheable`,<br />                 `createdby`, `createdon`, `editedby`, `editedon`, `publishedon`, `publishedby`)<br />                 VALUES<br />                (\’document\’, \’text/html\’, \’’.$modx->db->escape($_POST[’title’]).’\’, \’1\’, \’’.$ts.’\’, \’’.$pid.’\’,<br />                 \’’.$modx->db->escape($_POST[’frontpage’]).’\’, \’1\’, \’’.$tpl.’\’, \’1\’, \’1\’, \’’.$modx->getLoginUserID().’\’, \’’.$ts.’\’, <br />                 \’’.$modx->getLoginUserID().’\’, \’’.$ts.’\’, \’’.$ts.’\’, \’’.$modx->getLoginUserID().’\’)’;<br />       }<br />      else<br />       {<br />        $sql = ’INSERT INTO `’.$modx->db->config[’table_prefix’].’site_content`<br />                (`type`, `contentType`, `pagetitle`, `published`, `pub_date`, `parent`, `content`, `richtext`, `template`, `searchable`, `cacheable`,<br />                 `createdby`, `createdon`, `editedby`, `editedon`, `publishedon`, `publishedby`)<br />                 VALUES<br />                (\’document\’, \’text/html\’, \’’.$modx->db->escape($_POST[’title’]).’\’, \’1\’, \’’.$ts.’\’, \’’.$pid.’\’,<br />                 \’’.$modx->db->escape($_POST[’fullarticle’]).’\’, \’1\’, \’’.$tpl.’\’, \’1\’, \’1\’, \’’.$modx->getLoginUserID().’\’, \’’.$ts.’\’, <br />                 \’’.$modx->getLoginUserID().’\’, \’’.$ts.’\’, \’’.$ts.’\’, \’’.$modx->getLoginUserID().’\’)’;<br />       }<br />     <br />      $modx->db->query($sql);<br />        <br />      $did = $modx->db->getInsertId();      <br />      <br />      // Update the news_articles<br />      $sql = ’UPDATE `’.$modx->db->config[’table_prefix’].’news_articles`<br />              SET    `title`      = \’’.$modx->db->escape($_POST[’title’]).’\’,<br />                     `category`   = \’’.$aid.’\’, <br />                     `date`       = NOW(),<br />                     `time`       = NOW(),<br />                     `author`     = \’’.$modx->getLoginUserID().’\’, <br />                     `front_page` = \’’.$modx->db->escape($_POST[’frontpage’]).’\’,<br />                     `feed`       = \’’.$modx->db->escape($_POST[’feed’]).’\’,<br />                     `pages`      = \’’.$did.’\’, <br />                     `fp_only`    = \’’.$fp_only.’\’<br />              WHERE  `id`         = \’’.$aid.’\’’;<br /><br />      $modx->db->query($sql);<br /><br />      $html .= ’Article has been added.’;<br />     }<br />

          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Maybe you should take a look at the MaxiGallery code; it seems to have no problem creating folders dynamically.
            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