Joomla MVC let us use different views for our extensions/templates
I can use this
JRequest::setVar('tmpl','component');
in my index.php file to reroute the html rendering from component.php instead index.php
and it works fine , but i want to do something else ,
i want to override rendering by using file in a different folder not template/template_name/ folder but for example
plugins/myplugin/myview.php , does anyone know the way?
kinda this
JRequest::setVar('plugins/myplugin/','myview');
Related
From the CodeIgniter docs, I noticed that the view files are saved with .php extension, even if they only contain html. Is there a logical reason behind this?
It is not compulsory to save view files with the only .php extension we can also save them as HTML files, But to load the HTML views we also need to specify the filename with an extension like $this->load->view('my_view.html').
Also, you can check this link for the same discussion view extension in CodeIgniter 3
Q: When we load any class in CodeIgniter like we load the models, libraries in our controllers without specifying its extensions so how CodeIgniter loads the exact file with that name.
A: For this, There are the system functions defined in the CodeIgniter which concat the .php extension with the class name we pass e.g $this->load->library('form_validation')
For Example: How CodeIgniter 3 actually loads liberaries If you can check the system file in system/core/Common.php line no ~141 function
load_class for liberaries
So it will load system/libraries/Form_validation.php file
I hope this will make you clear that why view files in CodeIgniter saved with .php extension.
Codeigniter is a PhP framework, so it assumes the user is (eventually) going to use PhP.
Also, it isn't necessarily bad practice to always use .php instead of .html since .php handles html just fine. Could be viewed as potential future proofing your code.
One advantage of using the .php extension is that a server can be configured to not display the contents of the file. In other words, the lines of text (php code) that are eventually output to the browser (as html) cannot be seen directly. This provides a layer of security by hiding implementation details from the website user.
Because Codeigniter is a PHP MVC (Model-View-Controller) Framework. The view files are .php because they use PHP scripts. That's the idea, but it's not mandatory. You can include pure HTML. The view files are called by "name-of-the-view-without-the-extension".
I am working on a CodeIgniter - HMVC
What I know:
is I should not create assets like css,js,images inside the application folder in codeigniter, but I have a necessity for it.
**What I am trying to achieve is : **
to create a standalone module and trying to use it in another project. In that case, I really need to add the necessary css,js,images files into the modules folder it self.
The Error I get is:
You don't have permission to access /v7-bitbucket/application/modules/some_modle/assets/bootstrap.min.css on this server.
How do I overcome this?
Please advice.
Thanks.
There are 2 ways I can think of for you to access this data.
The first one is using an htaccess and a custom rule, which redirects certain files to inside the other directory. This way, the user will still have access to only certain specific files outside of the public HTML folder.
The second option is to use PHP and render the content of the file in custom tags.
Ex: Instead of entering <link href="<?= $path ?>">, you would do <style><?= file_get_contents($path) ?></style>. This would be harder to cache, and a bit harder to implement for images.
I would like to change/move the Model, View and Controllers folder from application folder and want them to be keep support in a new folder called app. Can someone please give me a solution which would work on CI-3*
application/
library
config
helpers
core
......
app/
model
views
controllers
index.php look for $application_folder and modify this.
You can move views separately using the $view_folder variable.
However, without changing the way the core of CI works you'd have to keep models/controllers inside of application.
Hi I am working on codeigniter for a while now and have met with an issue.
I use "localhost/controller/function" which is how codeigniter works.
Where controller classes are in controller folder in application.
I have a new codeigniter setup in root folder names "big" with its own controller, view, models etc. How can I run files in "big" like I do for my the original application.
I tried "localhost/big/controller/function", which obviously didn't work.
Please help, I am completely new with codeigniter.
just go to index.php of your application (big)
change/add line:
$application_folder = "applications/big";
I could not find the .htaccess file in CodeIgniter framework and i'm wondering how do they do route without it? Or it is somewhere hidden?
There is no .htaccess by default provided with codeigniter. They serve it through the index.php. .htaccess is only used to direct the urls to the index.php. This way codeigniter is working in environments where rewriting isn't allowed. Another way of getting controller and function is by query strings.
Anyway the actual routing is done in system/core/Router.php so you can read the code. Since Codeigniter is open source application that can't be hidden.