We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20014
    • 200 Posts
    Uggh, my first post in the forum, I haven’t felt like the odd man out since I first logged into my first linux help forum, hope you guys will be patient with me....because like many noob posts, this is a long one with more than one question to be answered. hope I posted in the correct area. I am on windows x64 xppro machine with mysql 5.1.41 database, php 5.2.11, modx 1.0.2 and phpMyAdmin 3.2.4 installed, I guess I am a bit of a slave to adobe to be working on my linux box, a much better server environment.

    I am absolutely amazed by modx, this is what a cms should be! within a day I was able to do exactly what I want, even customizing the menu of the site I am working on as it does in its static version. with that said please be warned, that I am a designer not a coder and there is still a few terms which go right over my head.
    my experience is this: solid solid css, I have never used a table in my career, other than that, a simple php cut and paste is about as far as I get with php coding.

    I have three very important questions and hopefully some of you powerusers can help straighten these doubts out, because once these are answered, I can deploy.

    anyway here it goes: (please reply as you would to any layman, once I understand everything else falls in place)

    1. I designed a php site for a client a few months ago, but that was to allow automated changes in the footer date and for the email, now this is the question I have:
    in the original form which I created for the client I began the form as this:
    <form id="form1" method="post" action="mail.php">
    and closed it with this
    <input type="hidden" name="next_url" value="http://clientssite.com/mail.php" /></form>
    which allowed the thank you page to load and execute this script:
    <?
    $to = '[email protected]';
    $subject = 'subject';
    $message = 'From: ' . $_REQUEST['name'] . "\n\n" . $_REQUEST['data'];
    $email = $_REQUEST['email'];
    $headers = 'From: ' . $email . "\r\n" .
                'Reply-To: ' . $email . "\r\n" .
              'X-Mailer: PHP/' . phpversion();
     
    mail ($to, $subject, $message, $headers);
    header("Location: thanks.html");
    ?>


    I know I couldn’t use this technique in modx, why bother?, but I did want to rescue the css styles for the form so I created a newchunk from the original contactform chunk and did this:

    <span class="headfont">Contact Me</span>
    <div class="commentform" id="commentform">Please feel free to ask me anything you want. Also, if you would like me to contact you via telephone please add that with your comments and or questions.</div>
    <form method="post" action="[~[*id*]~]" id="form1" name="form1">
             <fieldset>
             <div class="mrmrsradial" id="mrmrsradial">
           <input name="formid" type="hidden" value="ContactForm" />
            <label for="cfName"><span class="emailformtitles">Your name:</span>
    		<input name="name" id="cfName" class="formstyle" type="text" eform="Your Name::1:" /> </label>
            </div>
            <div class="emailinputfield" id="emailinputfield">
              <label><span class="emailformtitles">Your Email</span>
                <input name="email" type="text" class="formstyle" id="YourEmail" />
              </label>
            </div>
            <div class="textfield" id="textfield">
    <label for="cfMessage"><span class="emailformtitles">Message: </span>
    		<textarea name="Your Comments" id="cfMessage" rows="17" cols="30" class="formstyle" eform="Message:textarea:1"></textarea>
    		</label>
                <br />
              <span class="send"> <label> </label><input type="image" name="contact" id="cfContact" class="button" value="Send This Message" src="assets/templates/Dakota_Therapy_Theme/images/SEND.jpg"></span> </label>
            </div>
            <div class="send" id="send"></div>
              
            </form>
    </div>
     </fieldset>


    this made the css styles fall into place, but will it work and send an email to the cms or host, I see no reference to email or domain (I know I have to start thinking dynamically instead of static terms), I tested it on my local server and the thankyou page came up (modx’s original one) but no message in inbox....just wondering will it work when it’s deployed to the live server?

    2. This one is really goin’ to make someone upset, especially since it’s coming from a designer, but how do I create a splash page without messing things up? I know I know, I am sorry but the client’s profession actually makes it a nice intro into the main site. the main site is already set up, content, structure, etc, etc, just how do I go about doing this. I have already read this post

    http://modxcms.com/forums/index.php?topic=40027.0

    and I tried to follow it but I must be missing something. If you could tell me how to do this I would be deeply grateful. Plus how to link? wayfinder can’t be used, link to page id or what?

    3.the home link on the wayfinder menu takes me to the root directory not the page, also when I save in manager it does the same and the drop down menu from the top of the browser window when log in and viewing main content does the same. I have already experiment with make the main page not have a menu item then creating a weblink in wayfinder, but I have a feeling this isn’t the way to do it, though it works in the browser.

    ok I lied, couple more questions embarrassed

    4.there is a link in the main text body of the content which I want to point to another dynamic page, I used this:
    index.php?id=32 
    which works fine on the local server, is the way to do this? I styled the link a bit and I wanted to keep the css.

    5. uggh, forgot what I was going to ask, but the above four are REALLY NEEDED. I would just like to say that modx was the best find ever, I am a wysiwyg man and I have battled with the notorious JOOMLA! I even paid for an expensive plug in to work on templates which still require tables of all things, and after a couple attempts of tweaking it with the plugin and FF web developer toolbar for the css, I had to say to myself "screw this!" (sorry for the vulgarity)
    and I have already figured to use chunks to get my javascript to work marvelously and my menu to function as it did in the static site, I created the menu in pure css with rollover effects sans the help of javascript and it works! unreal!! I AM HOOKED AND I HOPE TO GOD THE DEVS OF THIS INCREDIBLE CMS GETS THE FINANCIAL BACKING THEY DESERVE, ALAS I AM POOR AND CAN ONLY GIVE KUDOS. :’( At least now, designers who are not coders, nor have the ability to enjoy endless lists of code, to have a backend to their designs without having to split the meeger income with a crew of co-workers.

    before in the U.S. it wasn’t a problem, I had friends who helped on the backend but I now live abroad in the third world and finding anyone who knows php in-depth is practically impossible. I really want to thank all of you before hand for taking the time to help me out.
      • 3749
      • 24,544 Posts
      I’m not clear on all your questions, but for #1, you could use your original code if you put it in a snippet and put a snippet tag where the post would go. It should work if the remote host has the mail() function turned on (many do not). If not, you’d have to use SMTP to send the mail. You’d probably want to use $modx->sendRedirect($modx->makeURL(n)) to forward the user to the thank-you page (where n is the document ID of the thank-you page).

      BTW, the SPForm snippet creates a simple contact form with a thank-you page. If you need a more complicated form, eForm is a little more work to implement, but will do just about anything.

      I think it might be relevant to several of your questions that rather than index.php?id=n, you can simply use a MODx link tag [~n~], where n is the document ID of the page you want to link to.

      Hope this helps.

      Welcome to MODx. smiley

      Bob
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 20014
        • 200 Posts
        great, so I can use the exact same code on my original? but how do I refer it to the thank you page? the above script worked fine since the static version was with the same host. 1and1 (i didn’t pick the host).

        ahhhhh hhhhaaaaa! I just understood what you said!, link wise, for example the link in the body just replace n with 32 and perhaps create a page where I use my spash as the template, and the enter button would be [~2~] and change my first page to an index menu of two?

        sorry for my enthusiasm...and thanks for such a prompt reply!
          • 20014
          • 200 Posts
          the code I used for the 1&1 servers uses these <? ?> for the php, yet the snippet has the tags like this <?php ?> does it matter?

          i did what you mentioned, I put my own code, the original code into the contactform page, and changed the action and next url to [~46~] and it went to the thank you page, I then created the snippet went to the thankyou page text editor and put it in as a html element, I guess only getting in to the server will prove to work or not.

          I cannot for the life of me, believe the ease of this even such a basic concept as what was just shown to me opened a whole world of possibilities!
            • 4310
            • 2,310 Posts
            <? ... ?> is the short tag version of <?php ... ?>.
            It’s safer to use the full version as not all hosting environments support short tags.
              • 20014
              • 200 Posts
              great!

              but again I apologize for a long post post here, but I am having some doubts about the email...and this is probably one of the most important things to make sure works prior to sending to the server for obvious reasons.

              I used this code as a chunk called customcontactforms, it’s exactly how it is in the static site.

                <form id="form1" method="post" action="mail.php">
                       <div class="mrmrsradial" id="mrmrsradial">
                        <label><span class="emailformtitles">Your Name</span>
                          <input name="name" type="text" class="formstyle" id="name" />
                        </label>
                      </div>
                      <div class="emailinputfield" id="emailinputfield">
                        <label><span class="emailformtitles">Your Email</span>
                          <input name="email" type="text" class="formstyle" id="YourEmail" />
                        </label>
                      </div>
                      <div class="textfield" id="textfield">
                        <label> <span class="emailformtitles">Your Comments</span>
              <textarea name="data" cols="30" rows="17" class="formstyle" id="yourcomments"></textarea>
                          <br />
                          <span class="send">
                          <input name="submit" type="image" id="send2" value="Submit" src="images/SEND.jpg" />
                          </span>          </label>
                      </div>
                      <div class="send" id="send"></div>
                     <input type="hidden" name="next_url" value="http://clientssite/mail.php" />
                      </form>
              </div>

              notice the first
              action="mail.php"
              ? and the
              <input type="hidden" name="next_url" value="http://clientssite/mail.php" />
              ? I changed both action and value to
              "[~46~]
              which is the link to the thank you page where I created a snippet of php code:
              <?
              $to = '[email protected]';
              $subject = 'subject';
              $message = 'From: ' . $_REQUEST['name'] . "\n\n" . $_REQUEST['data'];
              $email = $_REQUEST['email'];
              $headers = 'From: ' . $email . "\r\n" .
                          'Reply-To: ' . $email . "\r\n" .
                        'X-Mailer: PHP/' . phpversion();
               
              mail ($to, $subject, $message, $headers);
              header("Location: thanks.html");
              ?>
              changing the last line to
              header("Location: [~46~]");
              and inserted in via the html editor on the modx thankyou page.
              plus within the contact page (in the out of the box template) there had been a chunk inserted
              [!eForm? &formid=`ContactForm` &subject=`[+subject+]` &to=`[(emailsender)]` &ccsender=`1` &tpl=`customcontactform` &report=`ContactFormReport` &invalidClass=`invalidValue` &requiredClass=`requiredValue` &cssStyle=`ContactStyles` &gotoid=`46`  !]

              I simply changed the
              &tpl=`ContactForm`
              to customcontactform to reference the code but kept formid, this gave me the same error reporting (error email address or multiple sendings) while giving me the style I wished. (should I also have changed formid to customcontactform as well?)

              anyway, it didn’t work, at least it didn’t send me to the thank you page where the snippet for 1and1 server had been inserted. 1and1 needed an action="mail.php" and the code of the snippet with a location of mail.php for it to work.
              so my solution was to delete the code within the chunk customcontactform and put new code with the exact same code as the chunk ContactForm, I just added divs and classes as you can see here:
              <span class="headfont">Contact Me</span>
               Please feel free to ask me anything you want. Also, if you would like me to contact you via telephone please add that with your comments and or questions.
                    <p class="error">[+validationmessage+]</p>
              
              <form method="post" action="[~[*id*]~]" id="EmailForm" name="EmailForm">
              
              	<fieldset>
              		
              		<input name="formid" type="hidden" value="ContactForm" />
                             <div class="mrmrsradial" id="mrmrsradial">
              		<label for="cfName"><span class="emailformtitles"> Name:</span>
              		<input name="name" id="cfName" class="formstyle" type="text" eform="Your Name::1:" /> </label>
                               </div>
              
                             <div class="emailinputfield" id="emailinputfield">
              		<label for="cfEmail"><span class="emailformtitles">Email:</span>
              		<input name="email" id="cfEmail" class="formstyle" type="text" eform="Email Address:email:1" /> </label>
                               </div>
              
                              <div class="emailinputfield" id="emailinputfield">
              		<label for="cfRegarding"><span class="emailformtitles">Regarding:</span></label>
              		<select name="subject" id="cfRegarding" eform="Form Subject::1">
                                      <option value="General">General Questions</option>
              			<option value="Make An Appointment">Make An Appointment</option>
              			<option value="Press">Press Or Interview Request</option>
              			<option value="Request More Info">Request More Course Information</option>
              		</select>
                                 </div>
              
                              <div class="textfield" id="textfield">
              		<label for="cfMessage"><span class="emailformtitles">Message:</span> 
              		<textarea name="message" id="cfMessage" rows="13" cols="30" class="formstyle" eform="Message:textarea:1"></textarea>
              		</label>
              I left the chunk in the contact form (that had been inserted via the html editor) as is again here it is:
              [!eForm? &formid=`ContactForm` &subject=`[+subject+]` &to=`[(emailsender)]` &ccsender=`1` &tpl=`customcontactform` &report=`ContactFormReport` &invalidClass=`invalidValue` &requiredClass=`requiredValue` &cssStyle=`ContactStyles` &gotoid=`46`  !]

              I simply changed the
              &tpl=`ContactForm`

              and left the snippet of php code in the thankyou page..here it is again: (trying to avoid you having to scroll up and down)
              <?php
              $to = '[email protected]';
              $subject = 'subject';
              $message = 'From: ' . $_REQUEST['name'] . "\n\n" . $_REQUEST['data'];
              $email = $_REQUEST['email'];
              $headers = 'From: ' . $email . "\r\n" .
                          'Reply-To: ' . $email . "\r\n" .
                        'X-Mailer: PHP/' . phpversion();
               
              mail ($to, $subject, $message, $headers);
              header("Location: [~46~]");
              ?>


              the first example at the top of this page couldn’t find the following page, even with the [~N~] links inserted, I thought the action and the chunk in the html editor conflicted somehow, because I kept getting a page not found or I was sent to my error page. anyway, now testing the form it DOES NOW send me to the thankyou page (id=46) but will it still work on the server where the static method had worked before? I assumed, that even though my localhost doesn’t send email it would appear in the manager’s messaging system. should I set the email on apache to [email protected] for this to work?
              I hope you can understand my doubts, I just know that the final battle of setting up mysql and phpadmin and installation of the localsite to the remotesite on a linux server is waiting for me just around the corner and I would hate to have to troubleshoot a email form if I can install it. I will have to do all this late at night to insure traffic isn’t effected during the process...the site’s owner and clientele base is two hours ahead of me.

              thanks again guys for your answers so far...as I said, just one little thing has already solved so many things.

              odd though, I created the splash page, reset the order of the pages and now, the home botton goes straight to the main content page instead of rootdirectory (one up) as it had done before. but the manager link (localhost/clientssite/manager/index.php) sends me to the manager login and then once logged in, it sends me to the root directory instead of (localost/clientssite/manager/index.php) and sometimes saving in manager does the same thing...I am wondering if it is because the modx files reside within a subfolder folder rather than in the localhost directory by themselves, I dunno, I’ve never seen this behavior before with static html sites or php sites with a static tree before.
                • 3749
                • 24,544 Posts
                Wow, that’s the longest post here I’ve ever seen (not a criticism, just noting the new record). wink

                You can’t use a link tag in PHP code -- MODx doesn’t modify PHP code, it just runs it.

                Two solutions:

                1. Put the link tag as a parameter in the snippet call:

                [[snippetname? &linkID=`[~46~]` ]]


                Then in the snippet:

                header("Location:" . $linkID);


                2. (what I would do) change that header line to:

                $modx->sendRedirect($modx->makeURL(46));


                or, if you’re sending the link ID in the $linkID parameter:

                $modx->sendRedirect($modx->makeURL($linkID));


                Be sure to enclose the snippet parameter in back-ticks, not single quotes, and remember that parameters and variables are case-sensitive.



                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 20014
                  • 200 Posts
                  thank you so much bob ray, that clear things up considerably. so

                  I leave the webform as it is now, and once it redirects to the thankyou page, the script snippet will work as it did with the link formated such?

                  how about the ContactForm chunk in the html editor of my contact me page? remember I just modified the &amp;tpl= to reference the layout chunk named customcontactform. is there anything else I should do to it? such as delete &amp;cssStyle=`ContactStyles` (I tried to change ContactStyles to my css file, but it wouldn’t have it, hence the customcontactform chunk I created) or add customcontactform to &amp;formid=? There already exists in the chunk &amp;gotoid=`46`for the contact page, and the snippet already exists on [~46~] so is that location= within the snippet really necessary? I found it to be redundant since the code executing the mail to the server is already on the same page it refers to? though, heck, who am I to speak? I often sometimes envy coders, those who look at a terminal or text editor and see everything in their heads, I am way to visual, fine arts background and such...(excuses, excuses laugh)

                  and I apologize for the length of the post, I knew it was coming, because my opening sentence mentioned how I felt when I first logged onto a linux help forum way back...it was about how to hack a winmodem (try updating from the repos on a dial up...uggh!)on linux ...and it was successful because of people like you willing to roll their eyes and take compassion on the dreaded "NOOB" shocked laugh
                    • 1343 ☆ A M B ☆
                    • 2,213 Posts
                    Wow, quite a bit of reading so excuse me if I am skipping things...

                    eform will do what you want and the code in the first post appears to be fine. You don’t really need hidden fields to control how it works as most everything is set in the eform call.

                    Now the one issue in the last few posts is you have &amp; which will break your snippet call. Typically I disable the RTE (WYSIWYG/Tiny) on these pages. Click the page setting tab when editing the page and then uncheck richtext.

                    If you don’t then you need to be rather careful to remove all the amp; parts from the snippet call.

                    Hope that helps some
                      Patrick | Server Wrangler
                      About Me: Website | Tweets |  MODX Hosting
                      • 20014
                      • 200 Posts
                      I get ya, oops, just realize the chunk I was referring to is actually a snippet...I was copying and pasting from the html editor field directly to here sorry will turn off rich text...plus must remember to refer to chunk and snippet correctly [] {} sorry

                      turned off rich txt and everything went to hell, but I had the foresite to ctrl+c and ctrl+v prior, good now, thanks for the heads up!

                      how about that chang I made in &tpl field from &tpl="ContactForm" to the styled chunk I made(&tpl="customcontactform")something clicked in my head after seeing how easy wayfinder is when you set your menu up in css and set it in the xhtml before hand.? is that ok? it won’t break the code will it?

                      the original code I was referring to is this
                      [!eForm? &formid=`ContactForm` &subject=`[+subject+]` &to=`[(emailsender)]` &ccsender=`1` [u][b]&tpl=`customcontactform` [/b][/u]&report=`ContactFormReport` &invalidClass=`invalidValue` &requiredClass=`requiredValue` &cssStyle=`ContactStyles` &gotoid=`46` !]


                      is that ok? again I tried to change &cssStyle from ContactStyles to my own css file, but it didn’t take. I’m sorry I have written so much, it’s just that every other issue I have had, whether it was getting my javasript content to work, porting the template, creating content, organizing, seo, is all intuitive, this is the only roadblock I have run against, this is it, after this, it’s to the server. so I am actually amazed how simple this CMS is really, snippets and chunks, it’s incredible! I just wish I had more of a grasp of PHP to be able to see what I see when looking at a style sheet. embarrassed this is only the third day since I installed modx in my testing environment.