We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40447
    • 165 Posts
    Hi,
    I have this nice php guestbook that I want to use on my modx evo 106 website.

    If I enter the direct url to the file newmsg.php in my webbrowser the guestbook page shows up
    and everything is working.

    http://localhost/zundapp/assets/guestbook/newmsg.php

    If I use the following iFrame as content in the guestbook resource page:

    <iframe allowtransparency="" frameborder="0" name="guestbook" src="assets/guestbook/newmsg.php" style="border:2px #0000FF solid;position:absolute;left:216px;top:147px;width:590px;height:755px;z-index:14"></iframe>
    


    in modx, the guestbook page also shows up and everything is working.

    So this must mean that both the absolute url in the webbrowser
    and the relative path ="assets/guestbook/newmsg.php"
    in the iFrame content are correct.

    However when I try to use the same relative path in a snippet
    [[guestbook]]

    <?php include ("assets/guestbook/newmsg.php"); ?>
    as content on the guestbook resource page to call newmsg.php,
    I get the following error :

    PHP error debug
    Error: require_once(./extension.ini) [function.require-once]: failed to open stream: No such file or directory
    Error type/ Nr.: Warning - 2
    File: C:\xampplite\htdocs\zundapp\assets\guestbook\newmsg.php
    Line: 26
    Line 26 source: require_once(GB_ROOT_DIR.'/extension.ini');

    Ok,
    GB_ROOT_DIR inside newmsg.php is set to "." define('GB_ROOT_DIR', '.');
    and results in ./extension.ini which was working correctly in the browser url
    and also with the iFrame.

    If I chance GB_ROOT_DIR into this: define('GB_ROOT_DIR', 'assets/guestbook');
    inside the newmsg.php page then the snippet call works and the guestbook page
    shows up, but, all the links on the page are broken.

    So,
    Where does it go wrong with the snippet <?php include ("assets/guestbook/newmsg.php"); ?>

    I think I should not have to change the relative path setting inside GB_ROOT_DIR
    because it was working with the url in the browser and also with the iFrame content.

    I guess I have to use a different relative path in the snippet call but I don't see how yet.

    I don't want to enable allow_url_include as a work around in php.ini in the xamp server
    as this raises the risk of code injection.

    Thanks in advance
    Brian.
    [ed. note: sitecms last edited this post 14 years, 2 months ago.]
      • 40447
      • 165 Posts
      Hi,
      After a few hours of newbie-fighting with php I found that this php code in the snippet is working:
      header('Location: assets/guestbook/newmsg.php');

      But I still haven't figured out why include ('assets/guestbook/newmsg.php');
      isn't working.
        • 10208 ☆ A M B ☆
        • 1,780 Posts
        I honestly don't know if this will work but try calling the snippet uncached.

        [[!guestbook]]


          Frogabog- MODX Websites in Portland Oregon
          "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
          Having server issues? These guys have MODX Hosting perfected - SkyToaster
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Consider that with a snippet you are including code into the site's main index.php file, so any relative paths in the code would become relative to that index.php file. So using it as a snippet would require changing its own internal relative paths.

          Have you considered using Jot as a guestbook? It is fully customizable, and should do anything any guestbook app can do.

          http://wiki.modxcms.com/index.php/Jot

            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
            • 40447
            • 165 Posts
            Thanks for the replies. I have been php fighting with this guestbook for more than a day now. I am not (yet) a php pro but going there this year I promised myself. Susan you're right about this :
            any relative paths in the code would become relative to that index.php
            .
            I found that out the hard way with a css case. The css was called externally as a file. Inside the css paths were declared to pictures. I figured the relativity out between the css file path and the paths to the pictures declared in the css. That I have under control now. But in this case there is more to it. I managed to set the paths right and index.php is calling the guestbook correct but all the links on the pages are broken. Perhaps I can solve these paths too the same way.

            Anyway for now I am using an iFrame as content on the resource page where the php guestbook is called. This works perfectly, obviously, because with the iFrame there are 0 path issues. But I consider this a workaround.

            How to port third party web pages to the modx framework is well documented. But I think there should also be something documented for how to port third party php guestbooks
            to the modx framework. Modx doesn't have guestbooks packages and there are really nice and usefull opensource guestbooks out there. I found one for evolution (Stgb) but unfortunately way too simple.

            I will try Jot later this week. I have read about it to use it for comments, blogs, etc and also useable for a guestbook. Greetings Brian.
              • 40447
              • 165 Posts
              By the way here is the really nice php guestbook that I am working on. Save yourself hours (days) of digging the internet for a good php guestbook. This one looks good, tastes good and is professional.
              It has a full remote admin with professional configurations. The front-end is based on templates so you can reshape it anyway you want. The back-end is based on Mini-Templator, which is much more easy than Smarty but just as effective ! I really encourage you to have a look at Mini-Templator to see if it can speed up your workflow with websites. Greetings Brian.

              the php guestbook (opensource)
              http://sourceforge.net/projects/instphpmysqlgb/files/

              download
              http://garr.dl.sourceforge.net/project/instphpmysqlgb/ipmgb/1.03b/ipmgb103b.zip

              MiniTemplator
              http://www.source-code.biz/MiniTemplator/


                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Sounds a lot like Jot.
                  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
                  • 40447
                  • 165 Posts
                  Sounds a lot like Jot.
                  mmmm I'll report back on that "for guestbooks sake"