Jump to content

Trying to understand file locations, and paths/urls.


n0sleeves
 Share

Recommended Posts

I'm trying to understand url paths a bit better. I'm still a newbie to this so please forgive.

In the api docs, it says that $config->urls->root will take you to your site homepage, Well, for me, goes to the same page I am already on, not my home. Example is easiest so see here: site. The logo is supposed to go home. Does $config->urls->root  take you to the site folder?

Also, I am trying to understand file locations. I am so used to developing sites in the traditonal sense, not using the method detailed in the api. Maybe I just learn better from examples and I need more of them.

I want to send visitors to a thank you page after form submit. How do I reference the file and where do I place the file on the server? In the site folder? I don't need the thank you page to be a template or do I?

Thank you

Link to comment
Share on other sites

n0sleeves,

The reason the link from the logo always goes to the current page is because the href is blank. Have a look at the HTML source of rendered pages.

This is what appears in your source code.

<a href=""><div id="logo" class="center"><img src="/site/assets/images/logo2.png"></div></a>
 

So firstly you have the href inside the div tags - this is not valid HTML as it is. Something like this should do what you want.

<div id="logo" class="center"><a href="<?php echo $config->urls->root; ?>"><img src="/site/assets/images/logo2.png"></a></div>
 

Or you could quite easily just go with:

<div id="logo" class="center"><a href="/"><img src="/site/assets/images/logo2.png"></a></div>
 

since it is to the root. Using $config->urls->root is useful as a starting point to build onto when making a URL to a lower level, but for root I think it is probably superfluous.

Hope that helps.

  • Like 1
Link to comment
Share on other sites

Thank you for the reply. I have it working now since you pointed out my flaws. Still curious about how to reference another file. This is the code that takes the visitor to the thank you page (in bold red)

if ($mailSent) {
    header('Location: http://www.site.com/thank_you.php');
    exit;

How do I reference the thank_you.php file using processwire's api method? Where do I place the actual file also?

I'm guessing it's something like below? How do I reference others directors/levels since the code already ataches a forward slash? Am I off base? I can't seem to get my brain to think.

Thank you for your help

 $config->urls->root->assets->foldername 
 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...