-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to define module front controllers layout #7780
Allow to define module front controllers layout #7780
Conversation
Hello tonyyb! This is your first pull request on the PrestaShop project. Thank you, and welcome to this Open Source community! |
👍 |
@@ -1308,6 +1308,9 @@ protected function getThemeDir() | |||
public function getLayout() | |||
{ | |||
$entity = $this->php_self; | |||
if (empty($entity) && $this->controller_type === 'modulefront' && !empty($this->page_name)) { | |||
$entity = $this->page_name; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @tonyyb,
What do you think if we just use $this->getPageName()?
$entity = $this->php_self;
if (empty($entity)) {
$entity = $this->getPageName();
}
It seems to handle even more cases:
public function getPageName()
{
// Are we in a payment module
$module_name = '';
if (Validate::isModuleName(Tools::getValue('module'))) {
$module_name = Tools::getValue('module');
}
if (!empty($this->page_name)) {
$page_name = $this->page_name;
} elseif (!empty($this->php_self)) {
$page_name = $this->php_self;
} elseif (Tools::getValue('fc') == 'module' && $module_name != '' && (Module::getInstanceByName($module_name) instanceof PaymentModule)) {
$page_name = 'module-payment-submit';
} elseif (preg_match('#^'.preg_quote($this->context->shop->physical_uri, '#').'modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m)) {
// @retrocompatibility Are we in a module ?
$page_name = 'module-'.$m[1].'-'.str_replace(array('.php', '/'), array('', '-'), $m[2]);
} else {
$page_name = Dispatcher::getInstance()->getController();
$page_name = (preg_match('/^[0-9]/', $page_name) ? 'page_'.$page_name : $page_name);
}
return $page_name;
}
Hey @tonyyb ! What do you think of @Quetzacoalt91 's suggestion above? |
Hi @xBorderie @Quetzacoalt91 : I think that's a good idea ! 👍 |
Thank you! Could you try and squash those commits into just one? Another explanation of squashing. |
This is okay to keep the history like this @xBorderie, that's why I merge it. ;) Thanks @tonyyb. |
Fine by me :) |
Re-open : #7771 with good convention name.