
rosuandreimihai
Members-
Posts
41 -
Joined
-
Last visited
Profile Information
-
First Name
Rosu
-
Last Name
Andrei Mihai
rosuandreimihai's Achievements
-
URL link for custom module
rosuandreimihai replied to rosuandreimihai's topic in Addons, modules and themes developers
Hi again, I tried 2 methods, but none of them worked.. The first one, was to add a hookModuleRoutes in my controller, just like below: public function hookModuleRoutes($params) { return array( 'module-vpages-dpage' => array( 'controller' => 'dpage', 'rule' => 'flower-deliveries{/:id_country}{/:country}{/:city}', 'keywords' => array( 'id_country' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'id_country'), 'city' => array('regexp' => '[\w]+', 'param' => 'city'), 'country' => array('regexp' => '[\w]+', 'param' => 'country') ), 'params' => array( 'fc' => 'module', 'module' => 'vpages', 'controller' => 'dpage' ) ) ); } And then, in the controllers install: $this->registerHook('moduleRoutes'); That didn't worked, so I tried to override the Dispatcher class, by adding a custom module route: 'module-vpages-dpage' => array( 'controller' => 'dpage', 'rule' => 'flower-deliveries{/:setCountry}{/:id_country}{/:country}{/:city}', 'keywords' => array( 'setCountry' => array('regexp' => '[0-9]+', 'param' => 'setCountry'), 'id_country' => array('regexp' => '[0-9]+', 'param' => 'id_country'), 'city' => array('regexp' => '[\w]+', 'param' => 'city'), 'country' => array('regexp' => '[\w]+', 'param' => 'country'), ), 'params' => array( 'fc' => 'module', 'module' => 'vpages', 'controller' => 'dpage' ) ), When using that custom rule, the link http://europeanflora.com/flower-deliveries?module_action=list&id_country=44&country=Argentina&setCountry=44 was tranformed in http://europeanflora.com/flower-deliveries?module_action=list and it didn't worked and was redirecting me to the first page. Could some one tell me what am I doing wrong? I've spent hours of reading how it should be done and it should be just like the ones above.. Thank you! -
Hi, I am currently developing a new module for Prestashop and I would like it to have a nicer friendly url. Right now, the most that I managed was to create a page in SEO & URLS, but still I don't like it. The link to the page of the module is: domain.com/flower-deliveries?city=Dalton&id_country=21&country=United+States Instead of that I would like a link similar to the one below: domain.com/flowe-deliveries/Dalton-21-United+States.html Does anyone know how to achieve that? Thank you in advance!
-
Hi all, I am currently developing a custom module. What I want is to have a nice URL, because right now it looks like this: domain.com/flower-deliveries?city=Hamburg&id_country=1&country=Germany I already added a new page to link to the custom module, the page name is flower-deliveries, but still I have the parameters that I have to "hide". Instead, of that link above I would like a URL like this: domain.com/flower-deliveries-Hamburg-Germany.html Can it be done? If yes, how? I've tried with .htaccess, like this. but with no luck.. RewriteRule ^flower-deliveries-([^-]*)-([^-]*)-([^-]*)\.html$ /flower-deliveries?city=$1&id_country=$2&country=$3 [L]
-
Hi all, Please could someone help solve one big issue for my side? I want to add the homefeatured module to a custom module developed by me. I have altered the install function from homefeatured to add a new hook (cumstomCMS), created a function with hookcustomCMS() and added the below line inside my custom tpl file: {hook h='customCMS' setCountry=$smarty.get.id_country} But, even if the live editor shows me that the module was hoooked ok inside my tpl file, the products don't show at all.. Could someone help me and point me to the mistake I am making? Thank you!
-
Hi all, I have a problem regarding the homeFeatured module. This one is working perfect on the first page and in some other custom pages but not on a particular one First of all, I created one customCMS hook, that was attached to the homefeatured.php file like this: public function install() { $this->_clearCache('*'); Configuration::updateValue('HOME_FEATURED_NBR', 8); Configuration::updateValue('HOME_FEATURED_CAT', (int)Context::getContext()->shop->getCategory()); Configuration::updateValue('HOME_FEATURED_RANDOMIZE', false); if (!parent::install() || !$this->registerHook('header') || !$this->registerHook('addproduct') || !$this->registerHook('updateproduct') || !$this->registerHook('deleteproduct') || !$this->registerHook('categoryUpdate') || !$this->registerHook('displayHomeTab') || !$this->registerHook('displayHomeTabContent') || !$this->registerHook('customCMS') ) return false; return true; } public function hookcustomCMS($params) { return $this->hookDisplayHome($params); } Then, inside my .tpl file I am using this code to show it inside the front page {hook h='customCMS' setCountry=$smarty.get.id_country} But it doesn't work, even if it is being present if I use the live editor.. Could someone help me sort it out? Thank you!
-
Thanks, but I needed a new page that should have another friendly url generated dynamically. For each different parameter (country and city) there should appear some other link that could be directly accessed from outside the shop So, I created a new controller inside the same module that will redirect to a custom page. The first page contains all the links generated. The page can be seen at: http://europeanflora.com/flowers-world Now, all the links point to a new page, just like this: http://europeanflora.com/module/vpages/dpage?module_action=list&id_country=36&country=Romania&city=Bucuresti But, how can I maintain the Dispatcher to make a url rewrite something like this: mysite.com/flowers-bucurest-romania.html? Can I make that sort of page without loosing the parameters and still be able to pull them out using {$smarty.get.country}? Or should I just live the page just like this? I think that SEO would be more relevant if I make a friendly url..
-
Now that you managed to learn me something new, could you tell me how to manage the links inside the page just created? There will be some hundreds of them, pulled out from database, with links similar to mysite.com/flowers-country-city.html where country and city are parameters pulled from DB Should I create another module to maintain the new page that will be called for every link? Thank you!
-
Ok, I took your advice, I have created a module that has the following structure: modules/ modules/vpages modules/vpages/controllers modules/vpages/controllers/front modules/vpages/controllers/front/vPagesController.php modules/vpages/views modules/vpages/views/templates modules/vpages/views/templates/front modules/vpages/views/templates/front/vPage.tpl modules/vpages/vpages.php The vPagesController.php has the following strucure: class vpagesvPagesControllerModuleFrontController extends ModuleFrontController { public $errors = array(); public $display_column_left = false; public $ssl = true; public function __construct() { parent::__construct(); $this->page_name = 'vpages'; $this->context = Context::getContext(); } public function initContent() { parent::initContent(); $this->setTemplate('vPage.tpl'); } } And it should work by pointing to: mysite.com/index.php?fc=module&module=vpages&controller=vPagesController I also tried to lowercase everything just like this: mysite.com/index.php?fc=module&module=vpages&controller=vpagescontroller Nothing works, I still get a "This page is unavaiilable" Could you point me to the correct way? Thank you!
-
Hi Roja, I followed what you explained, I created a custom FrontController that points to the vPages.tpl, I added a new page under SEO & Preferences with the friendly url mysite.com/flowers-world but I'm getting only 404 This page is not available message Could you tell me what I am doing wrong? Thank you!
-
Thank you! It sounds more logical than my solution But, all the virtual pages (the links) are generated inside cms.tpl just like this: {foreach $vPages as $page} <li> {assign var="link_" value="flowers-{$page.country}-{$page.city}.html"} {assign var="id_link" value="{$link->getVirtualPageLink('107',$page.id_country,$page.country,$page.city)}"} {assign var="meta_title" value="Flowers in {$page.country} - {$page.city}"} <a style="color:normal" href="{$id_link|escape:'html':'UTF-8'}" title="{$meta_title|escape:'html':'UTF-8'}"> {$meta_title|escape:'html':'UTF-8'} </a> </li> {/foreach} How should I change the link to point to the new tpl? Thank you again!
-
Hi all, I have a custom CMS page with a link similar to this one: http://mysite.com/flowers-country-city.html The link is generated trough a override of the Link.php class using a custom function public function getVirtualPageLink($cms, $id_country, $country, $city, $alias = null, $ssl = null, $id_lang = null, $id_shop = null, $relative_protocol = false) { if (!$id_lang) { $id_lang = Context::getContext()->language->id; } $url = $this->getBaseLink($id_shop, $ssl, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop); $dispatcher = Dispatcher::getInstance(); if (!is_object($cms)) { if ($alias !== null && !$dispatcher->hasKeyword('vpage_rule', $id_lang, 'id_country', $id_shop) && !$dispatcher->hasKeyword('vpage_rule', $id_lang, 'city', $id_shop)) { return $url.$dispatcher->createUrl('vpage_rule', $id_lang, array('id' => (int)$cms, 'rewrite' => (string)$alias), $this->allow, '', $id_shop); } $cms = new CMS($cms, $id_lang); } // Set available keywords $params = array(); $params['id'] = $cms->id; $params['rewrite'] = (!$alias) ? (is_array($cms->link_rewrite) ? $cms->link_rewrite[(int)$id_lang] : $cms->link_rewrite) : $alias; $params['id_country'] = ''; $params['id_country'] = $id_country; $params['country'] = ''; $params['country'] = $country; $params['city'] = ''; $params['city'] = $city; $context = new Context(); $context->getContext()->cookie->__set('vp_country',$country); $context->getContext()->cookie->__set('vp_city',$city); $params['meta_keywords'] = ''; if (isset($cms->meta_keywords) && !empty($cms->meta_keywords)) { $params['meta_keywords'] = is_array($cms->meta_keywords) ? Tools::str2url($cms->meta_keywords[(int)$id_lang]) : Tools::str2url($cms->meta_keywords); } $params['meta_title'] = ''; if (isset($cms->meta_title) && !empty($cms->meta_title)) { $params['meta_title'] = is_array($cms->meta_title) ? Tools::str2url($cms->meta_title[(int)$id_lang]) : Tools::str2url($cms->meta_title); } return $url.$dispatcher->createUrl('vpage_rule', $id_lang, $params, $this->allow, '', $id_shop); } I tried to enclose the parameters inside some cookies but then I realized that the cookies would be available only if click event was fired, but it would not work on direct access of the link I have also a custom Dispatcher rule, similar to the one above 'vpage_rule' => array( 'controller' => 'cms', 'rule' => '{rewrite}-{country}-{city}.html', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'cms_rewrite'), 'id_country' => array('regexp' => '[0-9]+'), 'country' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'city' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*') ), ), So, can someone tell me how to solve this issue? To have the url parameters inside a CMS page from a custom link? What would be the best and simple way of doing it? Thank you!
-
Passing custom text to url rewrite
rosuandreimihai replied to rosuandreimihai's topic in Core developers
Never mind, I just figured it out by myself! I should have looked for the rule inside the dispatcher, now it works just fine -
Hi all, I have a new CMS page that is going to be used for displaying dynamic data from database depending on certain parameters passed via overridden Link.php class. If I don't create any Dispatcher rule for url rewrite, the link would show me the parameters Now, the task is to alter somehow the rewritten url link to actually include those parameters passed The link should look like: mysite.com/flowers-country-city.html The params are country and city and they are passed using the Link.php class as metioned Until now I have created the CMS page "flowers-" and the link displayed is "mysite.com/flowers-" but I don't know how to alter the rewritten url Could someone help me sort it out? Thank you!
-
Trying to create a custom link function
rosuandreimihai replied to rosuandreimihai's topic in Core developers
I purposely left the first assignment, the one you also mentioned just to be sure that everybody sees that I don't want that I will have a page with a lot of links just like /flowers-country-city.html, but when accessing them I want to be able to pull out the params city and country, crucial for the cms page So, I have made an override for the Link,php class and added a new function getVirtualPageLink, function similar to getCMSLink. The question is why am I getting that error, or how should I approach this task? Thank you again, Mihai