Redirect to a custom phtml file from a controller in Magento? - redirect

I have a Magento controller and a phtml file. How can I redirect to that file in my controller action? I searched the net, but found nothing. Ideas?
Thanks!

If you mean that you want to show the contents of your phtml-file when visiting the URL of the controller, you should follow this tutorial: Baobaz Controller Tutorial
It has everything in it you need. Even interaction between the controller and the template.
Remember to adjust the paths and class names to your solution.

Related

How to pass a variable to two different view from a controller in Laravel

I am working on developing a social networking site.
In my view folder there are two different folders:
1.layout:
Layout have app.blade file: This file contain an notification header like fb. example:
Notification example Image
2.user : User have home.blade file: it is contain home view.
Now when any user logs in it goes to home view first,Home view fecthing data from home controller Like this :
return view('home',compact('data','postblog');
But I also want to show a notification in notification section of app.blade file. So, My question is how can I send the data to that view too along with home view?
If you know any other way of doing this, please guide me.
app.blade.php can access your data directly. don't need extra options as mentioned above by Ray Cheng.
Or you can do that using view composer method For more : https://laravel.com/docs/5.4/views

how to create model, controller and view files in Croogo cms?

I am trying to create a contact form with validation in Croogo, I don't know where to create the ctp files and the controller for it. I did this in cakephp but I could not do the same in Croogo. Help me with this.
I have created it in the nodes folder. As this is the first time I am using this I struggled with it. I have created the view files and the controller files in the respective view and controller folder in the nodes folder.

Zend Layout Placeholder?

I am trying to create a sidebar in my layout that has the behavior of a placeholder. I want to be able to define the contents of this placeholder once per controller. So every controller can add custom content to the sidebar but without the need to define it in any view.
I am kind of confused on how to go about that with Zend_Layout. Any help?
I have tried something similar. Here is what you can do.
Place this type of code in the layout.phtml script file. Somewhere near the top. You don't have to but this way you 'know' what placeholders you're using. Doing this in the layout is also a good idea because you can wrap html divs are whatever here and not worry about it in the views. The views can just worry about the content. After this, you can add content to the placeholders from the controllers and the views.
$this->placeholder('blah');
$this->placeholder('sidebar');
$this->placeholder('blunk');
If you don't want to create them in your layout, then you can do it in the controller like so,
$this->view->placeholder( 'sidebar');
.
Now, you can either put content into it in the controller, or in the view script. Its a better idea to add the content in the view though.
In the layout you can then just echo the placeholders like so
echo $this->placeholder->( 'sidebar' );
All the views are executed BEFORE the layout is executed so any placeholders created by the views will be available to the layout to print out.
Also, controllers don't HAVE placeholders. Only views, and by extension layout, have placeholders like this so you have to declare them somewhere. Even if you declare them in the controller they still 'belong' to the view object.
I don't know if this helps at all but good luck. Tell me what you think.
How about adding a postDispatch() call to each controller?
public function postDispatch()
{
// code to populate/activate your placeholder
$this->view->placeholder('xxx');
}
This function will be called after your action completes. For more info, see Pre- and Post-Dispatch Hooks.
i have just implemented a solution to this that should work for most uses.
I store all of my placeholder.phtml files in the following dir:
/views/scripts/_placeholder
Within the placeholder i create directories for each Controller / Action that has a placeholder (as well as ROOT stuff). I then create a file for each placeholder.
e.g. Placeholder = sidebar. Controller = user / action = view
for the above we would store a file here:
views/scripts/_placeholder/user/view/sidebar.phtml
note: within the sidebar.phtml you will need to add : $this->placeholder("sidebar")->captureStart() and captureEnd();
if the plugin sees this file it will render it. If it doesnt find one then it wont.
Additionally the plugin will also look for the following and pull that in first:
views/scripts/_placeholder/sidebar.phtml
I can post the plugin if you want.
The only issue i have is i would like to now know if a placeholder has any data in it. That way i can create some layouts that are clever and will render what needs. DOes anyone know how to do this?

Link from an HTML file to a view

I have an HTML file that's loaded from a UIWebView. I'm looking to do the opposite - link from the HTML file to a different view controller. How would one go about doing this?
the html file is a local file within the app.
thanks for any help.
You can do this by adopting UIWebViewDelegate protocol and implement the webView:shouldStartLoadWithRequest:navigationType: method. Here you can capture all requests and selectively use them for your purpose.
Define links such as yourapp://yourviewcontroller/argument within the HTML page and parse them in the above mentioned delegate method and load the appropriate view controller.
try using three20 library
https://github.com/facebook/three20
there is a helpful class for this named TTStyledText which render html as well as custom links. just need to map the links with ur controller. Go through the samples in three20!
Sorry for the short answer, but there are a lot of parts to this. Check out this link.
http://forums.macrumors.com/showthread.php?t=463491
It looks like you might have to register the url with Apple. I know that for the maps application its able to do urls like map://... and I've seen other apps do it too, I just don't know the exact process.
Update: looks like this exampe from Apple should help.

Static HTML page navigation into an ASP.NET.MVC application

I'm sure there's a simple answer but I can't think of it.
I'm working with a designer who is using Dreamweaver to produce a series of static HTML pages and style sheets. These pages navigate to each other using standard anchors.
However, on a couple of pages there needs to be a navigation to a page under ASP.NET.MVC 2 (from here I do all the coding stuff to the backend) which has Form input etc.
What is the best way to ...
1: Navigate from a standard HTML page into ASP.NET.MVC 2(Home controller)
And/Or
2: The best way to have ASP.NET.MVC output the static HTML pages. Meaning the ASP.NET.MVC controller reads the static HTML (from a cache) then outputs it to the View
Hope this makes sense, thanks in advance.
Any links will be very much appreciated
If you're going to the root of an MVC-based site, if would just be the URL as the index view of the home controller is usually the default. Something like http://www.website.com. However, if you want a specific controller/view then the the syntax would be http://www.website.com/{controller}/{view}.
HTH