Let's say my project root is http://localhost/laravel-project
In the project I have navigation menu, the sample format of the link is
home"
So when I click the link the url on my browser is http://localhost/laravel-project/home
I do not know why if I have another link
home" and the route is Route::get('/invoice/show/{id}', 'Frontend\CommonController#show');
when I click the link, the previous home link will become
http://localhost/laravel-project/invoice/show/member it's supposed to be http://localhost/laravel-project/home.
The inside show method :
public function show(){
return view('frontend.invoice', ['subaccounts' => $this->subaccounts, 'menus' => $this->menus]);
}
I have tested it, the cause of the problem is the segments on the link invoice/show/1 if the link is only invoice then everything is fine.
Anyone knows what is wrong and how to solve this issue ?
Note : I am using a blade template
I managed to solve the problem by using the function {{url('linkName')}} in the link.
Related
In Laravel Controller I want to return a view and land the page on specific anchor tag. But I can't figure out how to write the return line/code, I tried this but that didn't work:
return view('viewIwantToReturn#andAnchorTag',compact(....
Please let me know if you have any suggestions on how to write it, so it lands on the anchor tag.
On redirect it works as expected:
return redirect('viewIwantToReturn#andAnchorTag');
I am returning the view from within edit method that also returns an object for editing, therefore I cant just redirect back.
Hi I use paginate() method for pagination it work fine, but a tag in blade file have problem my link like this:
http://localhost/blog/admin/news/?page=2
and when i click on them i'm redirect :
http://localhost/admin/news?page=2
and get 404 error and when click link like this:
http://localhost/blog/admin/news?page=2
it's work fine. what the problem ?
Why when use http://localhost/blog/admin/news/?page=2
redirect me an other page?
thanks.
I had the same problem. You can use the setPath() method to choose the right path. You can see the usage of that method here http://laravel.com/docs/5.1/pagination#displaying-results-in-a-view
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.
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).
I am creating a site in which I would like to go to another page via a custom menu. My menu code for the views/layout/main.php is:
array('label'=>'create wireframe', 'url'=>array('wireframes/create'), 'visible'=>!Yii::app()->user->isGuest),
A user can go to the wireframe creation page, but it passes the url index.php?r=user/wireframes/create
but I only want index.php?r=/wireframes/create. How can it pass the url? Are there any additions that I missed?
I guess you can try
'url'=>array('/wireframes/create').