Forums

Moving dev to live site

the_fitz 11 Sep, 2012
Hi all,

This is probably a little off topic, but here goes....

I have done all my development of my "special" modules with CF4, and they are working well. I did all this work on a dev (not live) site, but now I wan to move it to the live site.

In some of my code (especially my paypal code) there are some absolute urls like the "notify_url" which currently is https://testdomain.com/my_dev/index.php?option=com_chronoforms&chronoform=order_card&event=ipn

I will be using this on several sites and I want to make the urls "portable" so I don't have to change them all for each site.

Please help me to find and use the joomla variable for its base directory. I tried a couple of things but NOT!

notify_url = <?php echo $JOOMLA_BASE ?>/index.php?option=com_chronoforms&chronoform=order_card&event=ipn

Please help me out with an example. My Joomla install directory is https://testdomain.com/my_dev.

Thanks in advance.

Tom
GreyHead 12 Sep, 2012
Hi Tom,

There are two different groups of Joomla! PHP values that you can use here.

A) There are some Defined terms for Paths (that is folder paths not URLs) like JPATH_SITE, JPATH_ROOT, JPATH_BASE, JPATH_COMPONENT and JPATH_ADMINISTRATOR

Usually JPATH_SITE is the one to use if you are in the front-end.

Note that this doesn't include a final / separator so you need to add that. In Joomla! 1.5 you needed to specify the path separator using DS to handle both Windows and Linux servers. In Joomla! 2.5 I think this is supposed to be automated but I still add it.

So a path might look like JPATH_SITE.DS.'components.DS.'com_chronoforms'.DS.'includes'.DS.'some_file_name'

Here's an extract from the Joomla! Forums with a little more explanation:

JPATH_SITE is meant to represent the root path of the JSite application, just as JPATH_ADMINISTRATOR is mean to represent the root path of the JAdministrator application.

JPATH_BASE is the root path for the current requested application.... so if you are in the administrator application, JPATH_BASE == JPATH_ADMINISTRATOR... if you are in the site application JPATH_BASE == JPATH_SITE... if you are in the installation application JPATH_BASE == JPATH_INSTALLATION.

JPATH_ROOT is the root path for the Joomla install and does not depend upon any application.



B) If you want the URL - for the Notify URLs then use the JURI object which lets you access the current URL. Again there are several different methods. JURI::base(), JURI::root(), JURI::current()

You probably want to use JURI::root() for your URLs in the front-end.

Note JURI::root() does include the final \ separator so you don't need to include this and you don't need to use the DS in URLs so an example would be JURI::root().'index.php?option=com_chronoforms&chronoform=order_card&event=ipn'

There are a lot more JURI methods that you can use to work with URLs if you need to, check the Joomla! docs if you need them.


There is one more piece of generalisation that you might find useful. The current form name is available in $form->form_details->name so you could use JURI::root()."index.php?option=com_chronoforms&chronoform={$form->form_details->name}&event=ipn" to share code across different forms and sites.

Bob
the_fitz 12 Sep, 2012
Hi Bob,

Thank you for the in-depth answer. That gave me all the info that I needed, and more, for the future as well.

Tom
the_fitz 12 Sep, 2012
Hi Bob,

Well I tried it, but it is not working where I need it to.. But after rereading your response (below) I just wonder if I am doing it wrong.

I am working in the PayPal Redirect event and in the Return URL field... This is my contents...
<?php echo JURI::root().'index.php?option=com_content&view=article&id=8' ?>

does the Return URL field accept PHP?
OR
should I be using the curly brackets and put that string in custom code like?

//custom code//
$form->data['return_url'] =JURI::root().'index.php?option=com_content&view=article&id=8';
//end custom////
AND
//Paypal redirect Return URL field////
{return_url}
//end paypal redirect///

Thanks
Tom


Hi Tom,

There are two different groups of Joomla! PHP values that you can use here.

A) There are some Defined terms for Paths (that is folder paths not URLs) like JPATH_SITE, JPATH_ROOT, JPATH_BASE, JPATH_COMPONENT and JPATH_ADMINISTRATOR

Usually JPATH_SITE is the one to use if you are in the front-end.

Note that this doesn't include a final / separator so you need to add that. In Joomla! 1.5 you needed to specify the path separator using DS to handle both Windows and Linux servers. In Joomla! 2.5 I think this is supposed to be automated but I still add it.

So a path might look like JPATH_SITE.DS.'components.DS.'com_chronoforms'.DS.'includes'.DS.'some_file_name'

Here's an extract from the Joomla! Forums with a little more explanation:

JPATH_SITE is meant to represent the root path of the JSite application, just as JPATH_ADMINISTRATOR is mean to represent the root path of the JAdministrator application.

JPATH_BASE is the root path for the current requested application.... so if you are in the administrator application, JPATH_BASE == JPATH_ADMINISTRATOR... if you are in the site application JPATH_BASE == JPATH_SITE... if you are in the installation application JPATH_BASE == JPATH_INSTALLATION.

JPATH_ROOT is the root path for the Joomla install and does not depend upon any application.



B) If you want the URL - for the Notify URLs then use the JURI object which lets you access the current URL. Again there are several different methods. JURI::base(), JURI::root(), JURI::current()

You probably want to use JURI::root() for your URLs in the front-end.

Note JURI::root() does include the final \ separator so you don't need to include this and you don't need to use the DS in URLs so an example would be JURI::root().'index.php?option=com_chronoforms&chronoform=order_card&event=ipn'

There are a lot more JURI methods that you can use to work with URLs if you need to, check the Joomla! docs if you need them.


There is one more piece of generalisation that you might find useful. The current form name is available in $form->form_details->name so you could use JURI::root()."index.php?option=com_chronoforms&chronoform={$form->form_details->name}&event=ipn" to share code across different forms and sites.

Bob

GreyHead 13 Sep, 2012
Hi Tom,

does the Return URL field accept PHP?

No, none (or very few) of the simple text boxes accept PHP (most of the text areas do).

Instead use a Custom Code action to add the value to the $form->data array and then use the name of the array entry in the Return URL field as you have in the second example.

Bob
This topic is locked and no more replies can be posted.