Jump to content

SyntheticShield

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

About SyntheticShield

  • Birthday 12/28/1967

Contact Methods

  • AIM
    SyntheticShield
  • Website URL
    http://www.syntheticshield.com
  • Yahoo
    syntheticshield

Profile Information

  • Gender
    Not Telling
  • Location
    Bartlesville, OK

SyntheticShield's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Pikachu, that seems to work identically to HTTP_HOST, but would using SERVER_NAME be better since it would work on both test and production?
  2. So I should be using HTTP_HOST instead of DOCUMENT_ROOT?
  3. My goal was to create a constant that could be included on the pages, that no matter where it was located in the structure, would be able to find the template files, css, images, etc. using the following code: if($_SERVER['HTTP_HOST'] == "localhost"){ define('SITEURL', 'http://' . $_SERVER['HTTP_HOST']); define('SITEPATH', $_SERVER['DOCUMENT_ROOT']); define('CSS', $_SERVER['DOCUMENT_ROOT'] . '/css/'); define('IMAGES', $_SERVER['DOCUMENT_ROOT'] . '/images/'); } else{ define('SITEURL', 'http://' . $_SERVER['HTTP_HOST']); define('SITEPATH', $_SERVER['DOCUMENT_ROOT']); define('TEMPLATE', $_SERVER['DOCUMENT_ROOT'] . '/incs/template/'); define('CSS', $_SERVER['DOCUMENT_ROOT'] . '/css/'); define('IMAGES', $_SERVER['DOCUMENT_ROOT'] . '/images/'); } I put the above in a variables.php file that is in the includes folder (named incs) and I call it using the typical include statement. The problem is that when I use the constant to grab the CSS file, its not working when using: <link rel="stylesheet" href="<?php echo CSS . "template.css" ?>" type="text/css" media="screen" /> I can view the page source and it has the path right, but I cannot figure out how to get it to actually pull in the css file. I know the echo command is not correct, at least I dont think it is, but have not been able to figure out any other way. Also, is there a better way to define the constants to the file locations and have it automatically detect whether its on the test server or production and then be able to reference those locations no matter where it is in the structure?
  4. Ahh, awesome. Thank you so much for your help Rifts. It is very much appreciated.
  5. Oh. Well that is far, far simpler than I thought it was going to be. Ive been searching of and on for most of the day trying to find a workable solution that was not all convoluted and such and had not run across anything like that. If I could trouble you for the additional information, how would I tie that to the navigation menu? Its just a basic CSS ul/li menu with one sub level. All the web files are .php as I use includes to form the template structure if that makes a difference. My thoughts, initially were just to put the content in a file with just the basic p and h tags to make it semantically correct, call it into the div and just let the css take over from there. Thanks for the help.
  6. Is there a way to create dynamic content without the use of a Content Management System? I simply want to click on a link in my navigation menu and have that display the content in a div section and keep the content in a separate folder on the server. I didnt want to have to use a CMS to accomplish that because every other feature of it will be unused as I just simply want to display the content in a div when I click on the link. I use a simple test server on my Home PC that I use to format the articles in html from documents I have wrote in LibreOffice, so I dont really need all the features and sophistication of full blown CMS. But I also dont want a bunch of different files in my root folder if I can avoid it. I would rather keep the content in a separate folder and just pull it from there and display it on the main page when the link is clicked. Anyway, I dont know if its even possible or if its the best way, so I am open to suggestions as well. Some of the documents are quite long (like several chapters) and some are much shorter (just a few pages). Any help and ideas are much appreciated.
  7. I am setting up a site that is using MODx 2.2 Revolution. I had been using ValidForm Builder as my contact form generator and have used it for a while and really like it. One of the things I liked about MODx is that I was not tied to strictly using their plugins and so forth and that its generally pretty easy to integrate php code into the site via what they call snippets. Anyway, Im sure many here are familiar with MODx. However, the issue I am having is getting ValidForm to work in MODx. When you make a 'snippet' in MODx, it has to have a return. I have posted the code for a sample form below from the ValidForm Builder website. I created a snippet and added the below code to it to test things out. Knowing that the snipped had to have a return, I tried return ($strOutput);. That generates the form on the page, but it doesnt actuall process and send the form. The validation all works, but nothing else. So Im not sure if Im doing things wrong or what. On static pages you simply use: <?php echo $strOutput; ?> If I do that only, the form doesnt show up. So ultimately I guess Im trying to figure out how one would write a 'return' into the code so that it works. I tried putting the return after the closing bracket, but Im not sure that is the correct way to do it. Does anyone have any ideas or input? I know MODx has the FormIt extension, but I really like ValidForm and would love to get it to work since, at least on static pages, it is easy to work with and set up. I need to redirect, back to the home page, after the form is submitted, but MODx handles that a little differently and I will have to figure that out after I get the form working. Thanks in advance for any help. <?php //*** Include the library. require_once("libraries/ValidForm/class.validform.php"); //*** Create an instance of the form. $objForm = new ValidForm("contactForm", "Required fields are printed in bold."); //*** Add the Name field. $objForm->addField("name", "Your name", VFORM_STRING, array( "maxLength" => 255, "required" => TRUE ), array( "maxLength" => "Your input is too long. A maximum of %s characters is OK.", "required" => "This field is required.", "type" => "Enter only letters and spaces." ) ); //*** Add the Email field. $objForm->addField("email", "Email address", VFORM_EMAIL, array( "maxLength" => 255, "required" => TRUE ), array( "maxLength" => "Your input is too long. A maximum of %s characters is OK.", "required" => "This field is required.", "type" => "Use the format name@domain.com" ), array( "tip" => "name@domain.com" ) ); //*** Add the Remarks field. $objForm->addField("remarks", "Remarks", VFORM_TEXT, array( "maxLength" => 2000 ), array( "maxLength" => "Your input is too long. A maximum of %s characters is OK.", "type" => "Enter only characters, punctuation, numbers and spaces" ) ); //*** Set the general alert. $objForm->setMainAlert("One or more errors occurred. Check the marked fields and try again."); //*** Set the label of the submit button. $objForm->setSubmitLabel("Send"); //*** Default output. $strOutput = ""; //*** Check the form. if ($objForm->isSubmitted() && $objForm->isValid()) { //*** HTML body of the email. $strMessage = "<html><head><title></title></head><body>"; $strMessage .= $objForm->valuesAsHtml(); $strMessage .= "</body></html>"; //*** Mail headers. $strHeaders = "MIME-Version: 1.0\r\n"; $strHeaders .= "Content-type: text/html; charset=utf-8\r\n"; $strHeaders .= "From: Awesome website <form@awesomesite.com>\r\n"; //*** Send the email. mail("owner@awesomesite.com", "Contact form submitted", $strMessage, $strHeaders); //*** Set the output to a friendly thank you note. $strOutput = "Thank you for your interest. We will contact you as soon as possible."; } else { //*** The form has not been submitted or is not valid. $strOutput = $objForm->toHtml(); } ?>
  8. Uggggh, nevermind, I got it. I was all off base, LOL if($_SERVER['HTTP_HOST'] == "localhost"){ // For local development define('SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/template'); define('SITEPATH', $_SERVER['DOCUMENT_ROOT'] . 'template'); } else{ // For production web define('SITEURL', "http://" . $_SERVER['HTTP_HOST']); define('SITEPATH', $_SERVER['DOCUMENT_ROOT']); } $URL= SITEURL; header ("Location: $URL");
  9. Im not sure that it is possible, but I thought I would post and ask anyway. I want to use a page redirect such as: <?php header("Location: http://www.redirect-to-home.com/"); exit; ?> However, due to the nature of the redirect and the header having to be sent first, Im not sure how I could use a variable or probably better, something like HTTP_HOST. In a post I made elsewhere on here, someone posted this code: if($_SERVER['HTTP_HOST'] == "localhost"){ // For local development define('SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/template'); define('SITEPATH', $_SERVER['DOCUMENT_ROOT'] . 'template'); } else{ // For production web define('SITEURL', "http://" . $_SERVER['HTTP_HOST']); define('SITEPATH', $_SERVER['DOCUMENT_ROOT']); I began thinking then, I wonder is something like that could be used as a page redirect as a very basic and simple prevention to direct access to a specific folder on the site? But Im not sure how to make it work, Im just not that experienced in PHP yet. I dont know if using an index.html file would be better over an index.php file either. Im still experimenting a little trying to figure things out. So is there a way to use a php variable to redirect someone back to the home page? I know you can use .htaccess and things like that as well, but I wanted to see if this could be done also. Thanks in advance for any help.
  10. I had actually been thinking about that, whether or not you could just pull the page title from the file name. Id love to do it for no other reason than just to learn the code, but I have to also think practically to and when it comes right down to it, I dont think anyone will ever notice that I dont have page names set or that they are static text vs. php derived.
  11. I think that in the big picture of things, you are absolutely correct. My thought was that Ive done all this other cool stuff (well cool to me cause I ultimately do it so little) why not this one more thing. But overall, as you said, its something people just arent going to notice or really care about.
  12. Yeah, Im getting error messages when using the code posted: I first got: Parse error: syntax error, unexpected T_STRING, expecting ')' on line 1. I thought that may be due to the mission quotation mark, so I added one and then got Fatal error: Can't use function return value in write context on line 2 What I was really after was just setting page title in one location/file. Then having the php code check for what page it is on and then pull the title from the file. Just to keep with the overall template I was making where I had one location to edit things across the site. I have the template structure set up to do that, now I just wanted to use variable to add information like page titles.
  13. Thank you all for the extremely quick replies. Very helpful. I really need to spend more time here and learn what I can. I usually go through these phases where I need to learn something building a web page or two, then dont use it for a long time and have to start over. Thank you all for your help so far.
  14. off of this comment, and no code given, why can't you simply state the title using the <title> element? but Well, you could, and that would probably be easier and more simplistic. I was trying to think down the road a bit in that as pages are added, but I guess it would be six, one half dozen either way. I was after, I suppose, a central location where page titles could be added and just have the php code do the rest.
  15. Do you mean that actual code structure? Sorry, dont want to sound like a complete doofus, just want to make sure I answer accurately.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.