Jump to content

image url path inside php tag, how is this possible with processwire?


danielholanda
 Share

Recommended Posts

I have this form in my html which works perfectly locally. Once I had this as a template my form doesnt work well. This has a calendar button available and here is the problem. I already had this php applied:

<?php
$myCalendar = new tc_calendar("date3", true, false);
$myCalendar->setIcon("_php/calendar/images/iconCalendar.png");
$myCalendar->setPath("_php/calendar/");
$myCalendar->setYearInterval(2012, 2022);
$myCalendar->dateAllow('2012-08-30', '2022-08-31');
$myCalendar->setDateFormat('j F Y'); 
$myCalendar->writeScript();  
?>

This means that I would have to paste this code which I have applied to any inner url I have in the html such as this example:

<input type="image" src="<?php echo $config->urls->templates?>_img/submit_button.png" id="input_img" name="submit" />

I've tried inserting only echo $config->urls->templates?. This way:

<?php
$myCalendar = new tc_calendar("date3", true, false);
$myCalendar->setIcon("$config->urls->templates_php/calendar/images/iconCalendar.png");
$myCalendar->setPath("$config->urls->templates_php/calendar/");
$myCalendar->setYearInterval(2012, 2022);
$myCalendar->dateAllow('2012-08-30', '2022-08-31');
$myCalendar->setDateFormat('j F Y'); 
$myCalendar->writeScript();  
?>

If I wanted the url to work how should I do it with processwire?

Link to comment
Share on other sites

If what Antti said above has been taken care of at some point, this might be the problem here:

$myCalendar->setIcon("$config->urls->templates_php/calendar/images/iconCalendar.png");

Try doing it this way instead:

$myCalendar->setIcon("{$config->urls->templates}_php/calendar/images/iconCalendar.png");

Of course that would only work if the path for this particular icon is /site/templates/_php/calendar/images/iconCalendar.png.

Link to comment
Share on other sites

Hello Teppo and Apeisa,

Yes, the calendar I'm using is not part of processwire. I have this file in the inner html (I dont know how you call this honestly) so I will place a picture of my path. I already tried the code you told me:

<td>
<?php
$myCalendar = new tc_calendar("date3", true, false);
$myCalendar->setIcon("{$config->urls->templates}_php/calendar/images/iconCalendar.png");
$myCalendar->setPath("{$config->urls->templates}_php/calendar/");
$myCalendar->setYearInterval(2012, 2022);
$myCalendar->dateAllow('2012-08-30', '2022-08-31');
$myCalendar->setDateFormat('j F Y'); 
$myCalendar->writeScript();  
?>
</td>

I will upload two pictures. One with the result I have once I put this code and the desired effect. Form.calender is how I have it working with the same path on my html/css. Form.code is the result after placing your code+

I will upload two pictures. One with the result I have once I put this code and the desired effect. Form.calender is how I have it working with the same path on my html/css. Form.code is the result after placing the same code into the CMS and placing the code above.

I just dont understand why it doesnt work if on my html/css and seen with MAMP its perfect and once applying it into processwire it doesnt work. Its a php file which has nothing to do with processwire...

Really, thank you for the help!

post-663-0-95533900-1347351075_thumb.png

post-663-0-66518300-1347351273_thumb.png

post-663-0-98413800-1347351283_thumb.png

Link to comment
Share on other sites

Maybe it helps but I just observed that at the begginingn of the html I have this code to initialize calendar:

<?php
require_once('_php/calendar/classes/tc_calendar.php');
?>

I;ve tried to put {$config->urls->templates} in all cases and it still does not work correctly. Therefore there are three url inside a php which are giving me problems. I thought that I didnt had to do anything with the url as its inside the php I dont need to redirect it with {$config->urls->templates}.

i really dont know how to follow up... Thanks if somebody can help me.

Link to comment
Share on other sites

There's two configs for urls and paths.

$config->urls->... returns web urls

$config->paths->... returns web server path

Mainly for frontend code like including css and script or image you would need ->urls

For including libraries or using file_exists, you can take ->paths

Also check out the cheatsheet I've done, that will give good reference over the api. http://www.processwire.com/api/cheatsheet/

  • Like 1
Link to comment
Share on other sites

I write here to let you know I found an answer to my problem so if anybody has something similar look here.

First of all you don't need to add any prefix inside a path inside a php created by you. It works as the path written by you. So adding {$config->urls->templates}. before the path doesnt make any difference. My problem was the following...

I learnt that a php process cannot occur inside the templates folder. Basically what you need to do is to put the folder with the process, so in my case folder _php containing all the relevant data, outside this folder. For example as I did inside /site/. Redirect the path and everything should work.

Dani

P.D. Really thanks to everybody who helped. Especially the cheatsheet you sent. All that is very valuable data.

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

×
×
  • Create New...