simonGG Posted October 22, 2016 Share Posted October 22, 2016 Hi there, i developt a single page website where home.php includes the template file php's. So my template files are not considered to be viewed as they are. Only in context with the home. Because of that i want that the view button in edit mode allways links to the root page. Is this possible? Thanks in advance && regards Simon Link to comment Share on other sites More sharing options...
tpr Posted October 22, 2016 Share Posted October 22, 2016 A simple session->redirect($pages->get(1)); exit(); won't do in your template files? Edit: you would probably need to wrap the redirect into a condition $page->id != 1 to allow your template code run on the homepage. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted October 22, 2016 Share Posted October 22, 2016 The view tab is hookable so you could do a before hook and change the property of that hook. https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module#L898 Link to comment Share on other sites More sharing options...
Jonathan Lahijani Posted October 23, 2016 Share Posted October 23, 2016 On 10/22/2016 at 7:43 AM, tpr said: A simple session->redirect($pages->get(1)); exit(); won't do in your template files? Edit: you would probably need to wrap the redirect into a condition $page->id != 1 to allow your template code run on the homepage. Shouldn't return $this->halt(); be used instead of exit(); ? 1 Link to comment Share on other sites More sharing options...
tpr Posted October 23, 2016 Share Posted October 23, 2016 Probably yes, but without "return" (there is no function context). Link to comment Share on other sites More sharing options...
LostKobrakai Posted October 23, 2016 Share Posted October 23, 2016 26 minutes ago, tpr said: but without "return" (there is no function context) You're correct, that there's no function context, but a return statement does also stop the execution of code in files loaded by require/include statements. Most often a $this->halt() without return doesn't make much sense. 2 Link to comment Share on other sites More sharing options...
tpr Posted October 23, 2016 Share Posted October 23, 2016 Thanks, so that's why I noticed it's not working as I expected in certain cases. Link to comment Share on other sites More sharing options...
simonGG Posted October 24, 2016 Author Share Posted October 24, 2016 Sorry for the late replay - and thanks for your help. I ended up with this in all template files - it's a multilingual Site (): $pages = wire('pages'); $session->redirect($pages->get(1)->url); exit(); Without get(1)->url it redirected me to ...myurl/de/pageName/1 - maybe this has to do with the fact that ist is a multilingual site? Thanks a lot + regards Simon Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now