Laravel based app - Adding a page but how? - php

I downloaded an app that uses the Laravel framework. I never heard of his framework before and therefore have my problems adding a new page.
I googled the whole day but cannot figure out how to add a simple page. I am therefore sorry asking this simple to answer question but I just need to add one page...nothing more.
Can anyone help me here? I figured out that the app works with routings.
There are subfolders in the folder /views called "item", "contact", "error" and so on.
In "item" I have php files like "add.php", "edit.php" and so on.
I need a page called "editplus.php" where I just copy the contents of "edit.php" with some changed content. That's it
I added a link in the menu but when I click "editplus" I will get a 404 error.
So there must be a file where I add the infomation, that "editplus" must show to my file "editplus.php"
I really looked in almost every file but cannot see where i would do that.
Can someone point me in the right direction?
Any help is appreciated.

You can simply do this by adding a route to app/route.php file
1. you can simply return your content like this and it will be displayed on page
Route::get('foo/bar', function()
{
return 'Hello World';
});
you can do it using a controller
Route::get('user', array('uses' => 'UserController#showProfile'));
more details of controllers here http://laravel.com/docs/4.2/controllers
Laravel is simplest framework of all.

Related

How to change Sign up page design in Moodle

I am new to moodle and i am using 2.9. I have a separate design for Signup page (HTML5 & CSS). How to integrate this page ?
I know the process of changing the default Login page like this
In config.php of my theme
'login' => array(
'file' => 'login.php',
'regions' => array(),
'options' => array('langmenu'=>true),
),
Where my Custom login page is login.php which is placed in my layout folder. So in this way i can takeover Login page design with my new design.
But i don't see any signup array in config page for Registration. So anyone can tell me how to do this change ?
Edit - I have checked this file moodle2\login\index_form.html I can see the signup design. But my issue is that file index_form.html has Moodle core CSS if i add my CSS there it will conflict also i dont know how to load the CSS from my theme folder to index_form.html.
Can anyone guide me ?
I already checked Moodle.org forum but not able to find the process.
Thanks In Advance
Lorry
Further to what #davosmith mentioned, you can actually use the existing auth/email plugin as a base for your plugin, So:
Copy auth/email and rename it to whatever you want, for example auth/foo. And rename all other instances of "email" to "foo".
Copy the login/signup_form.php to your plugin directory
in your auth/foo/auth.php file, add a function:
function signup_form() {
global $CFG;
require_once($CFG->dirroot.'/auth/foo/signup_form.php');
return new login_signup_form(null, null, 'post', '',
array('autocomplete'=>'on'));
}
Modify the auth/foo/signup_form.php to whatever you want
Hiii,
I'm one of the Moodler who working with Moodle.
to edit the signup page go at the following location and open the signup.php file.
./moodle/login/signup.php
in that file you can see at bottom of the page three lines.
...
echo $OUTPUT->header();
$mform_signup->display();
echo $OUTPUT->footer();
in which $mform signup->display(); create a form yu can comment and write HTML for your sign up form.
But make sure about the Action URL and the validations.
$mform is the object that create form and its class file is signup_form.php.
Hope it helpful for you ... Good Luck ['}
If you are wanting to avoid making changes to the core code in Moodle (which should almost always be what you want), then you can create a new signup form from scratch by first creating a new authentication plugin (in auth/NAMEOFPLUGIN).
When you create the authentication plugin, you should make sure that the 'can_signup' function returns true, that the 'user_signup' function does whatever processing is needed to create the new user account and that the 'signup_form' function returns a custom Moodle form that contains the fields you want.
It is possible to further customise this form by outputting custom HTML elements (using $mform->addElement('html', 'The HTML to output'); ). I would not advise completely abandoning the Moodle form (i.e. to replace it with hand-coded custom elements), as that will not be compatible with the signup code in login/signup.php (as well as losing the validation rules that are supported by the forms library).

Phalcon multi module with shared layout

I am new to Phalcon php framework and I got this problem. I want for every module to have simple view. For example:
user's view will say: 'hello this are my users'
articles's view will have: 'this are all the articles'
so in this case I need common layout (or whatever) where are all my head, css tags, also my footer, my nav bar and so on.
for this purpose I followed this repo.
So... in my /modules/Home/module.php I have:
$di['view'] = function() {
$view = new View();
$view->setViewsDir(__DIR__ . '/views/');
$view->setLayoutsDir('../../common/layouts/');
$view->setTemplateAfter('main');
return $view;
};
in /modules/common/layouts/main.phtml I have all my html, heads etc..
in /modules/Home/views/index.phtml I have "hi there"
in /modules/Home/views/edit.phtml I have "edit my home screen"
now when i go to "/" ( root dir ) it calls home/index, and I see ONLY "hi there" and nothing else.
Is it possible this to be done ?
You may check their github mvc samples, https://github.com/phalcon/mvc/tree/master/multiple-shared-views
In your code you are pointing to/modules/Home/views/index.phtml but your url is home/index it is all case sensitive, so I suggest 2 things: rename Home to home in your file structure and if that still does not work go to your HomeController look for the indexAction and just echo something to see if the code gets executed. Then report back your results

how to check which controller is calling pthml page in php

I have a page in UI that has some data set in it(a textbox) .
Now i need to check where this data is set from ?
My steps were :
1. Right click on elemnt in the browser.
2. Select "inspect element" .
3. From there, I managed to find the PHTML page that is actaully displaying the data I am searching for.
In the PHTML page, "$this->resources" does the job of holding data.
Now the question is , how can i find where this data is being SET ?
Obviously a controller will do that. So i had searched for "$this->view->resources" in my project to find the respective controller, but it didn't fetched me the exact result.
Any other tips other than what I am trying to do .
P.S I am using PHP ZEND framework.
Thanks for reading .
Regards,
Sagar
I think, you want get Controller and Action names?
Using:
Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
Zend_Controller_Front::getInstance()->getRequest()->getActionName();
In the same folder where 'view' folder with PHTML temlates is located, should be 'src' folder.
In it should be folder with the same name as your module.
In this folder should be the controller, with particular method (action) corresponding to your PHTML template. CamelCase in the action name maps to hyphenation in the template file name (CamelCaseAction => camel-case.phtml).

How to make a template overwrite for mod_menu with alternative layouts for link outputs?

I understand and love template overwrites. I need to do some heavier changes to the menu output (basically making the output work better with Bootstrap) - but only for certain menus.
Currently in Joomla 3 there are the following in the mod_menu/tmpl folder:
default.php
default_component.php
default_heading.php
default_separator.php
default_url.php
If I want to change the classes I'd copy the default.php into my mytemplate/html/mod_menu and change it. Great, no problem.
If I want to change the link outputs to go along with that I can copy the default_component.php to mytemplate/html/mod_menu and change it. Great, no problem.
If I want to have the choice of having a different "Alternative Layout" I'd rename the mytemplate/html/mod_menu/default.php to newlayout.php, then select it in the admin module manager for that menu. Great, no problem.
Here's the problem: If I want to have the link output changed for certain menus but not all of them I figure I'd change default_component.php to newlayout_component.php like I did above which would correspond to the newlayout.php...but that doesn't work.
Questions:
1) How to have alternative layouts for each of the default_component.php, default_heading.php, default_separator.php, default_url.php template files (not just an overwrite)?
2) I would think default_url.php is the one that would affect the link outputs but it seems it's default_component.php that does. So what does each one of those do? I couldn't find any information on joomla.org about that.
Thanks!
The alternative layout feature only works for the main file (default.php), not for the sublayouts (default_component.php, ...). So you have to create your own newlayout.php which then can load newlayout_component.php, or use the default_component.php. In fact, the default_component.php will be used as fallback if no newlayout_component.php is found.
The code switches over the $item->type of the link. 'separator', 'url', 'component' and 'heading' are handled by the 'default_'.$item->type, everything else will use default_url. So a plain URL should indeed be generated by default_url.php, not default_component.php. If it behaves differently, it's likely a bug.

Zend Plugin found in view not in layout

I've got a plugin that retrieves a list of buttons.
When i call this plugin from the view (echo $this->GetAdminButtons()) it works fine.
But I need to call this plugin from the layout.phtml and when i do, the application just stops (white screen, no output)
When i try to get the exception message i get this error:
Plugin by name 'GetAdminButtons' was not found in the registry;
used paths:
Zend_View_Helper_Navigation_: Zend/View/Helper/Navigation/
Zend_View_Helper_: Zend/View/Helper/:./views/helpers/
In the application.ini
resources.view.helperPath.Admin_View_Helper = "Admin/View/Helper"
Which confuses me because it works fine in the view .phtml files
Thanks in advance,
Continuing the discussion from the comments. Try moving the resources.layout lines in your config so they are after the resources.view ones (my suggestion in the comment had things the wrong way round).
I think your issue is that the layout is being initialized before the view is, which is why the view paths don't exist in the layout.

Categories