When we start with template or control the website URL become necessary information. Here are two method to retrieve base url:
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
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
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
For example we like to move in blog section
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 $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 pathRead More...