I'm new to codeigniter environment. I have this existing system and I am trying to duplicate one of the admin pages which I thought would work if i just copy, rename and paste.
Example:
(original files and working)
application\controllers\admin\calculator.php
application\views\admin\calculator.php
it can be access by domain.org/admin/calculator
(duplicated)
application\controllers\admin\calculatorduplicate.php
application\views\admin\calculatorsduplicate.php
tried accessing by domain.org/admin/calculatorduplicate
but showing 404
I also added the navigation link inside this file.
application\views\admin\header.php
What am i missing? I didn't want to change anything inside the file yet, just want to duplicate the page. Please help.
Firstly, first try to understand how CodeIgniter binds its URLs.
In URL:
http://codeignitersite.com/controller/method/parameter_one/parameter_two/[parameters].....
Controller is the Controller class which must have the same name as of its Filename and also as in URL.
Method is the Controller method to be accessed.
In above case, the class name also needs to be changed to:
class Calculatorduplicate {
To avoid any 404 error.
Related
Im new to typo3 and ive been trying to develop an extension for it. When I load the plugin to the page i get and error:
Sorry, the requested view was not found.
The technical reason is: No template was found. View could not be resolved for action "search" in class "LoginController".
In the login controller i have a function searchAction and I do have a template inside
\Resources\Private\Templates\StoreInventory\Search.html
What might be the error? I followed the documentation for extension development by typo3. I even downloaded the code from GIT and tried using that but no luck.
TL;DR: It should be placed at Resources/Private/Templates/Login/Search.html
explanation:
From your question I can tell you've used the documentation on https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/4-FirstExtension/6-adding-the-template.html
It is not wrong, but you've missed a vital step. When you take a look at the path they are using you'll see that a lot is done automagically. Let's break it down.
They have a controller with an action and a template related to it in the following path
controller:
\MyVendor\StoreInventory\Controller\StoreInventoryController
action: listAction
template: EXT:store_inventory/Resources/Private/Templates/StoreInventory/List.html
If you look closely you'll see that the template path is made up from several components.
the extension (EXT:store_inventory)
the default template directory path (Resources/Private/Templates)
The Controller name without the controller suffix (StoreInventory)
the Action name without the action suffix (List)
the .html suffix
If you take that information and apply it to your case it would be:
the extension (EXT:your_extension_name)
the default template directory path (Resources/Private/Templates)
The Controller name without the controller suffix (Login)
the Action name without the action suffix (Search)
the .html suffix
So the end result would be something like
EXT:your_extension_name/Resources/Private/Templates/Login/Search.html
It is true that you can use typoscript to change this behaviour or set overrides or extended templating for instance. But I think you're working from the default, and this should be the working path for you now
First check your templateRootPaths in Configuration/TypoScript/setup.typoscript
And set accordingly.
Try placing the file at \Resources\Private\Templates\Search.html as \Resources\Private\Templates is the default path unless you have altered it.
Laravel 5.7.
If I navigate to a page that does not exist, I get 404 error page handling.
That view is located in vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Views/404.blade.php
However this file extends:
#extends('errors::illustrated-layout')
This is located in the same folder, and is named illustrated-layout.blade.php
So I guess that the errors:: part points to the specific folder., e.g. vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Views/
Question: Is this type of pointer something that could be created manually, so a person wouldn't have to write the entire path to a specific folder, when extending a view? Would make things much more clean.
You can add a view namespace and achieve the same result.
For example, you can add the following in AppServiceProvider#boot:
$this->app['view']->addNamespace('admin', base_path() . '/resources/views/admin');
and let's suppose you have a blade file in resources/views/admin/layouts/master.blade.php
you can access it with admin::layouts.master
I am using SS 3.02 and have made a lots of modification in the core files. I am facing the issue that I am trying to set the color of the navigation background dynamically. This works fine for pages other than security/login page. Suppose I am getting the value in $navbgcolor, this shows up well on home page or about us page or any other page. But this does not show up on the Security/login page. Any help would be greatly appreciated. Thanks.
Firstly, it is never a good idea to alter the core files as this prevents you from easily updating your version of SilverStripe. You could miss out on bug fixes and important security updates.
The reason this isn't working on the login page is because the login page works from the Security controller which directly extends Controller. Your code (presumably in Page_Controller) will be completely bypassed.
Here is a way you could apply your code to all controllers, without touching the core:
<?php
class MyControllerExtension extends Extension {
public function onAfterInit() {
//... Your code here...
}
}
In your config file you would apply your new controller extension to Controller.
If you're using _config.php
Object::add_extension("MyControllerExtension", "MyControllerExtension")
If you're using YAML (recommended)
Controller:
extensions:
- 'MyControllerExtension'
You can learn more about extensions here: http://doc.silverstripe.org/framework/en/reference/dataextension
Also to let you know, you can create specific template file for the Security login pages by creating action sub-templates. Example is if you created a file in your theme called "Security_login.ss" you can call in variable, change the mark up etc.
Note the convention here is the filename is called the name of the class in this case "Security" then "_" followed by the name of the action to be rendered by your controller ("login" in this case).
As mentioned by micmania1, the golden rule for developing in SilverStripe is...
"Don't hack the core or modules!"
Instead as pointed out use extensions to decorate classes, or use subclasses if you have to.
Being new to Cake on PHP, I am trying to work out if I have a URL, what would be the easiest way to find the controller code for it?
The URL on my local machine is something like:
http://foofoofoo.local/protected/admin/org/edit/1
I have worked out that the location of the view for this file is at this location on my machine:
/var/www/MyApp/protected/app/views/org/admin_edit.ctp
I thought what I'd do is do a search throughout the entire codebase for anything referencing admin_edit.ctp. I found two entries, and changed them to see if I had found the point where the view is called, but despite changing the file name on these entries - the app still works when I visit the URL: http://foofoofoo.local/protected/admin/org/edit/1
I just want to see where the admin_edit.ctp file is being called within the site.
URL: http://foofoofoo.local/protected/admin/org/edit/1
This means I can assume you have a added a route in your /app/Config/routes.php. Where this is pointing can not be said since we don't have access to this file.
Why can I assume you have added this to your routes? Because the posted URL is not matching the CakePHP Conventions which clearly states that controllers should be defined in plural. Since the URL will be accessing the Controller directly through the Controller, unless a route has been specified, I know that the OrgController does not exist. Why?
Try Inflector::pluralize('Org'). It will return 'Orgs' to you. And thus meaning the controller should be called OrgsController and you should be accessing this Controller via the following URL.
http://foofoofoo.local/protected/admin/orgs/edit/1
In this OrgsController there should be an action (function) called admin_edit(), because you have prepended the org with Admin, which is a prefix.
It can be possible that the /protected part, is part of the URL as well, but do not know where your main /App is located and what part of the URL is pointing to the /app/webroot/index.php file.
The Views can be found at /app/View/Orgs/*.ctp.
If you are still having trouble finding your files. Please start with the Blog tutorial written by the Cake Community. This tutorial describes all the neat built-in tricks and will get your first app running in no-time. Please read that first!
If you are still having trouble, feel free to update your question and add the /app/Config/routes.php file.
Under Cake 1.3, if your application has an AppController (check if the file app/app_controller.php exists), you can put this code in the beforeFilter method:
debug($this->params);
It will print an array on your app pages when you are in debug mode, with the name of the controller and the action used.
Array
(
...
[controller] => controller_name
[action] => action_name
...
)
If the AppController does not contain any beforeFilter method, you can just create it:
function beforeFilter()
{
debug($this->params);
}
I think this is a route issue but I'm not sure. I have a page with this URL:
siteurl.com/kowmanger/titles/titles/edit/$id
I'm trying to find out that when I'm on this page I load the titles page it says page not found so I need to tell it that the $id is just a paramter so I can use it to get the data of the title.
UPDATE :
So I decided to change my titles controller so that there's a edit and add function inside of the titles controller that way they dont' have separate controllers when they are in fact methods.
So now I have:
kansasoutalwwrestling.com/kowmanager/titles/titles - list of titles
kansasoutalwwrestling.com/kowmanager/titles/titles/add - addnew form
kansasoutalwwrestling.com/kowmanager/titles/titles/edit/$id - edit form
I don't have any routes set up so far for this. For some reason though I"m getting the same page for both of these page.
kansasoutalwwrestling.com/kowmanager/titles/titles/add - addnew form
(right link url) kansasoutalwwrestling.com/kowmanager/titles/add -
addnew form
I need a route so that it'll show the correct url if the add method is accessed.
Also I need to set up a route so that if the correct edit link is accessed it sees the id attached to the end of the url and it'll accept it so that I can do a my database query to get the title data.
UPDATE: So to reiterate I have a module(subfolder) called titles. Inside of the module I have a controller called titles and inside of that controller I have 3 functions called index(), add(), edit().
I tried using Chris's suggestion on the routes but its not routing correctly. Also wanted to mention I'm using wiredesignz modular separation framework if that matters.
Any additional ideas?
Possible answer based on your post, not one hundred percent your entire structure but if i had to guess based off the post I would try this as my routes first..
$route['titles/titles/edit/(:any)'] = 'titles/titles/edit/$1';
$route['titles/titles/add'] = 'titles/titles/add';
$route['titles/titles'] = 'titles/titles';
$route['titles'] = 'titles/index';
Are you using custom routing in your configuration files ?
The general routing protocol used by codeigniter is like this:
domain.com/controller/methode/param1/param2/param3
This being said, your url
siteurl.com/kowmanger/titles/titles/edit/$id
corresponds to something like this :
class Kownmanger extends CI_Controller
{
public function titles($titles, $action, $id)
{
}
}
In case you are using sub-folders in your controllers folder, what I have just said will change, Could you please tell us what's your directory structure ?