We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27385
    • 15 Posts
    I’ve got two quick questions for two different things I want to do:

    #1: First thing is that I want my folders to be non-entities on my modx site (in other words, I want somebody when they type in http://www.my-website.com/about/ for it to go to http://www.my-website.com/about/index.html). So, I thought of created a unique template for folders called "For Folders" which included access to a snippet [[for_folders]] and then would output a php header() command to go to the index of the given folder. The problem I had though is that the variable I need to create the forward url is the url inputted into the web browser. I tried using a php
    $SERVER_(PHP_SELF)
    but that alas just gives me the true index.php page. The other thing I tried was using MODx’s [(site_url)] variable, but apparently this only outputs "http://www.my-website.com/" -- and nothing else. Any ideas? This is a remarkably simple thing. Another route I took was rather than using a snippet (since I really don’t know how to input MODx variables into a snippet anyways), and use the meta http-equiv tag in the folder template to do something like this:

    <meta http-equiv="Refresh" content="1; URL=[(site_url)][*alias*]/index.html"/> 


    But alas this only works for first-level folder roots, and it does client-side forwarding something that I didn’t really want to do.

    #2: The other thing I wanted to do was to create a "this page last edited" value on the bottom of every page displayed on the site. So, what I did was put this in the html of the template:

    [center]
    This page was last edited on: [[lastedited]]
    [/center]

    The unfortunate thing that this did was produce a number which counts the number of seconds since Jan. 1st, 1970 until the time the document was published. Is there another MODx value that I can use to output the actual date, or do I need to write the php program to convert these seconds into an actual date through a snippet? If I need to write one, has one already been written?

    Thanks,

    -Andy
      • 25663 MODX Staff
      • 12,272 Posts
      The first thing can be accomplished with a combination of Alias Path URLs and your snippet, I think. Not sure about the second.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Make a snippet with this code:

        return date("j F Y", $modx->documentObject['editedon']);


        Keep this in mind if you’re using QuickEdit http://modxcms.com/forums/index.php/topic,2881.0.html
          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
          • 27385
          • 15 Posts
          The date snippet is awesome and works great. Thanks for the help! The alias idea though hasn’t worked out. I got it to work for the top-level folders (http://my-website.com/top-folder/) but can’t get it to work for daughter folders. Maybe I’ll write a php script that loops and accesses the mysql db for the parent folder names. Are you sure there’s no other MODx variables that would give the present location of the file in the folder tree? i.e. if I’m at http://my-website.com/folder1/folder2/ it would note that the actual url is http://my-website.com/folder1/ rather than just the http://my-website.com/ (what [(base_url)] returns?).

          Thanks,

          -Andy
            • 18397
            • 3,250 Posts
            If I understand correctly, you have a few normal folders and when a visitor enters that address in you want it to go to that folder / index.html right? If so you should not need to do any scripting whatsoever as that is the default server behavior. If you want them to show in your menu just create a weblink.
              • 27385
              • 15 Posts
              I don’t think I’m explaining what I’m looking for clearly enough.

              Here’s what I want a folder to do: just to be a folder, without content, and that when somebody’s browser pointed to the folder it automatically forwards them to the folder/index.html. As it is, if I just create the folder and put content in it and people go to website.com/folder/index.html they get sent to the error page. If I create an index page within that folder and they go to website.com/folder it doesn’t go to the index.html page. I suppose I could make every folder a weblink pointing to the index page below . . .

              Then again maybe it’s just my installation of MODx. Although all of my previous installs have had the same problem. Working strictly with aliases I cannot get folders to forward to their index.html file, and I can’t rename a folder’s alias "index" because then all the folders’ aliases would be /index.

              Thanks for your help, I hope I haven’t been a pain . . .

              This thus far has been my only problem with MODx. I forgot to mention that it is transforming our massive website. I’ll post the link in the other forum as soon as the site is ready to go.

              -Andy
                • 32241
                • 1,495 Posts
                you can use $modx->makeUrl(doc_id);
                It will generate the current document link, so if you have the folder located under parentfolder, then this is the outcome ’parentfolder/folder.html’

                Another array that you might want to check is $modx->documentListing. Use print_r to get the whole data outputed to the screen, and you will understand why I want you to check this one out.

                I can’t provide you with the solution, but I hope those advice will be useful to achieve what you want.

                Sincerely,
                  Wendy Novianto
                  [font=Verdana]PT DJAMOER Technology Media
                  [font=Verdana]Xituz Media