eZ Community » Forums » Developer » MVC
expandshrink

MVC

MVC

Monday 15 September 2014 10:42:35 am - 3 replies

Hi all,

I am a little bit new to ez publish.we are going to create our project according to mvc format.means creating 3 folders for mvc and create seperate models controllers for them.

in controller I have wrote this function

function view_pagelayout(){   $Result['content'] = $tpl->fetch('Views:pagelayout.tpl'); }

is this the correct way to redirect?

I need some suggestions,corrections  with my code.

Monday 15 September 2014 7:31:50 pm

Sorry, I have a hard time understanding the context:

1) are you developing using the eZ4 or eZ5 stack?

2) do you want to render output or redirect?

3) if you are using eZ4 stack and for some reason do not like to use the default MVC implementation (eZ4 already uses the MVC pattern. MVC is not about "using 3 files"blunk.gif Emoticon, you should probably take a look at the existing ezonrails extension ( http://projects.ez.no/ezonrails ).

Trying to reinvent mvc-inside-mvc is usually a lot of pain as you need to take care of access-policies, caching, conflicts with the existing url routing and so on.

Modified on Monday 15 September 2014 7:32:33 pm by Gaetano Giunta

Wednesday 17 September 2014 5:16:06 am

Hi ,

Thank you for the reply.I am using ez4.

I want to redirect  to a page.not render.

I want to call a function 

 

function view_pagelayout(){   $Result['content'] = $tpl->fetch('Views:pagelayout.tpl'); }

in controller and in url 

it shpuld be dispaly in this format 

 view_pagelayout/pagelayout 

Wednesday 17 September 2014 8:06:50 am

Hello upeksha,

If your trying to redirect to a page than what your showing in example code is the wrong way to do this!

Like Gaetano said what your suggesting in general regarding custom mvc is a very bad idea and you should not do it this way.

Now on to your redirection issue. Can you provide an example url your trying to redirect to?

See there are several different best practices when it comes to url redirection (to a page) and they are a little hard to grasp at first so knowing which type of redirection you need to use would help us guide you to the right answers here.

eZ Publish Module View Redirection

$module = $Params['Module'];
 
return $module->redirectTo('/news/list');

Fallback to Stock PHP Redirection

At the very least you can always use standard redirection in php as a fall back if you don't know how to use eZ Publish builtin module view redirection or 

$location = '/page/url/string';
 
header( "Location: " . $location );
 
eZExecution::cleanExit();

Try using module view redirection first as it is strongly recommended.

I hope this helps!

Cheers,
Heath

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from