include a php file in magento admin panel - php

I am creating a module called "Web" in magento 1.7.2. Folder structure is like app/code/local/Company/Web/ then Block, controllers, Model, etc, Helper. Again under controllers creating Adminhtml folder and IndexController.php file. Under Adminhtml folder ProductController.php file is there. I have another one file which is in my root folder called reader.php file. I want to include that file in my ProductController.php file. But unable to do so. I have tried by the following code:
$basePath = Mage::getRoot();
include($basePath.'/reader.php');
Please help me how to include the file.
Thanks in advance.

Mage::getRoot() gives you the app folder. You should use Mage::getBaseDir() instead. That will give you your absolute base dir.

Related

app/Views/templates folder is not found in CodeIgniter

Folder which is said to be where all the page templates located at could not be found with the following error: cd: templates: No such file or directory.
Will it be okay to re create the folder or is there something missing and need to be restored ?
Yes you have to create your folder app/Views/templates/ and add your templates inside.
CodeIgniter does not create the folder automatically.

How to set up codeigniter?

I'm trying to set up Codeigniter in my mac, but with no luck. When loading every page, appears a blank page.
I'm following the Codeigniter tutorial from the official site.
Checked the base URL configured in config.php, but seems to be ok, now: http://localhost:8080/
Also, the directory where there is the file that I'm trying to open seems to be in the correct folder: nfs://192.168.64.2/opt/lampp/htdocs/application/views/pages
The pages.php code is the next:
<?php
class Pages extends CI_Controller {
public function view($page = 'home')
{
}
}
I expected to load about.php and appear the header, about page and footer.
to load the view in codeigniter, you need to add below line of code in your controller function.
$this->load->view($page);
note: I am assuming that you have all the view pages are located at the route of application/views/ folder.
When you download Codeigniter and is extracted, generate a "Codeigniter xxx" folder with files. Is necessary to copy this folder to htdocs folder and rename with the name that you want for your project.
If you copy the files instead the folder inside htdocs, could produce this problem.

load a page inside a folder in codeigniter

I have changed the name of codeigniter and placed htdocs then in application folder I have created a new folder in that new folder again I created some folders for different web pages in each and every folder I added controllers,models,view files. Now I want to access a controller file which is in the new folder.
I tried with default route but not working..Can anyone suggest
Create as many folders as you want inside the controller model and view folders in CodeIgniter and not outside them if you really want to organise them.
Remember to set base URL in application/config/config.php file and default router inside the application/config/routes.php file.
If you have problems please comment below describing errors.

How to I move my javascript resources into a local folder?

I wrote a small app using laravel 5.2. I tried to keep all of my code in one folder located outside the app folder.
I created a folder called modules. Inside the modules folder I have a folder for vendor name. Then, inside the vendor folder, I have a module folder which contains my code.
Here is a simple folder structure
app modules/vendor name/module name/...
I managed to move my controllers, views and a route file into the module name folder.
How would I move all of the javascripts located in the public folder into my module name folder so that everything inside is in the same folder?
Additionally, I have a lot of questions about the views being in the module folder. Is it a better practice to use $this->publishes() to publish views to the resources/views folder that comes with laravel? If so what are the benefits?
https://laravel.com/docs/5.2/packages
The benefit to publishing the views is that the end user, should they want/need to, then has the option to modify the views.
As for the javascript, its completely fine to contain the javascript in your modules folders as the docs mention. You have 2 options as to how they're then used. You can either choose to publish them which moves them into the public folder, or you can include them in your build process if you use elixir/gulp, etc. See https://laravel.com/docs/5.2/packages#public-assets
Edit:
To publish assets such as javascript files (they could in theory be anything, be that images, css, etc.) use the following from your packages service provider.
public function boot()
{
$this->publishes([
__DIR__ . '/path/to/script.js' => public_path('vendor/my-package'),
__DIR___ . '/path/to/another.js' => public_path('vendor/my-package'),
]);
}
The above will move both script.js and another.js into the /public/vendor/my-package folder. Just to explain __DIR__ is a PHP 'magic' constant which gives the directory the current php file is located in and public_path() is a Laravel function which gives us the location of the /public folder as some users choose to rename this folder to their specific configuration.

Codeigniter 3 HMVC wiredesignz showing 404 error

I downloaded HMVC files from here and set up my CI 3 installation using these file
Place the MX folder in application/third_party folder
Place the files in application/core MY_Loader & MY_Router
$config['modules_locations'] = array(APPPATH.'modules/' => '../modules/',);
Created a folder module in application. Inside module created welcome/controller and welcome/view
In welcome/controller I copied the default welcome controller and in welcome/view welcome_message.
I deleted both files from application/controller and application/view.
Now I am getting 404 error.
You change name of folder "module" to "modules".
And in modules folder:
You must rename controller and view folder to controllers and views.
Hope this help :)

Categories