HELP LINE

Please contact us any time if you need assistance on:

  • appRain installaton
  • Component, Plugin, Addon, Theme Configuration
  • Code Guide line
  • Documentation and Manual
  • Any appRain bug fixig

For any clarification email us now »

appRain CMF
info@apprain.com

Ticket

Work with URL and Directories paths

When we start with template or control the website URL become necessary information. Here are two method to retrieve base url:

App::Config()->baseUrl()

This method runs everywhere in appRain environment. We can pass sub part as parameter to append with the base URL for example:

// Return like www.example.com/blog/bycat/5
App::Config()->baseUrl('/blog/bycat/5'); 

We must add a slash (/) at the begin of sub part. Sometime we need to convert the URL in 'https' format. This is a common practice when we work in any secure page. To convert it in secure URL we pass a 2nd parameter like bellow.

// Return like https://www.example.com/blog/bycat/5
App::Config()->baseUrl('/blog/bycat/5',true);

Same task can done by another method $this->baseUrl(), But it's recommend to use only in template and controller.

Well, Templates designers feel very slothful to write baseUrl method to fetch theme address because, it require passing theme name each time. To make it easy we have another two methods like bellow

App::Config()->skinUrl();
$this->skinUrl();

These method works exactly like baseUrl function. See following examples

// return www.example.com/themeroot/themename
echo App::Config()->skinUrl() ;

 // return  www.example.com/themeroot/themename/images 
echo $this->skunUrl('/images');

We can use "filemanagerurl" to fetch file manager URL. The attached "/uploads/filemanager" sub part with the return value.

// return www.example.com/uploads/filemanager
echo App::Config()->filemanagerurl () ; 
// return www.example.com/uploads/filemanager/logo.png
echo App::Config()->filemanagerurl ('/logo.png') ; 

Now lets see how we can work with directory path. Following functions can use to serve the purpose

App::Config()->rootdirl) ;

This method return the root path where we have hosted the project like bellow

//  return like '/home/public_html/' 
echo App::Config()->rootdirl () ; 
//  return like 'd:/xampp/htdosc/website/components'
echo App::Config()->rootdirl ('/components/') ;  

Most of the time we require to fetch the towards "webroot" we can use following method for it

//  return '/home/public_html/webroot' 
echo App::Config()->basedir () ; 
//  return '/home/public_html/webroot/uploads/filemanager'
echo App::Config()->basedir ('/uploads/filemanager/') ; 

To fetch file manager path we can call simply this

// return /webroot/uploads/filemanager/
echo App::Config()->filemanagerdir(); 

"skindir" this method is use to get current theme directory. See following example

// return /development/view/rainboo/
echo App::Config()->skindir(); 

There are two special function to redirect website in other URL. Most frequently use

$this->redirect($URL,$Mode,$https);
App::Config()->redirect($URL,$Mode,$https);

For example we like to move in blog section

App::Config()->redirect('/blog');
exit;

It is recommended to call "exit" after calling this function and it always receive relative path not full URL.

We have another two parameters $mode and $https to customize redirection pattern.

By default this method work with PHP header which is dependent on output buffer. But if we pass 'javascript' keyword then it redirect by using JavaScript window.location.

App::Config()->redirect('/blog','javascript');

By default $https mode is false, but if we pass true then it redirects to secure URL. See following example:

 // redirect to https:://www.example.com/blog
App::Config()->redirect('/blog',null, ture);

We have another method "transfer". This method also redirects URL but display a message during redirection and remain the message on the screen for few seconds. App::Config()->transfer ('http://www.example.com/blog','Your are going to redirect in new location'); We have another advantage is, we can pass some value in 'POST' method. To pass the value we have to set it by using magic method. See following example :

App::Config()
 -> getPostVars(
    array(
        'field1'=>'value1',
        'field2'=>'value2',
        'field3'=>'value3',
    )
) 
->transfer (
  'http://www.example.com/blog',
  'You are going to redirect in new location'
);

The "transfer" method always expect Full URL with "http" not a relative path

Read More...

Highlighted News

Latest version of appRain (0.2.1) is ready for download. New module is developed to apply validation and easy JavaScript programming. Lots of fixes done and made it stable.