PrestaDesigner10 Posted June 8, 2017 Share Posted June 8, 2017 Hello, how can I reorder the links in the the native module "Widget link" (folder module/ps_linklist) I'm using prestashop 1.7.1. Thanks! 1 Link to comment Share on other sites More sharing options...
PrestaDesigner10 Posted June 22, 2017 Author Share Posted June 22, 2017 Up... Link to comment Share on other sites More sharing options...
netvico Posted April 19, 2018 Share Posted April 19, 2018 Up... Link to comment Share on other sites More sharing options...
jgamio Posted April 20, 2018 Share Posted April 20, 2018 No the best way I do direct on database check ps_link_block you see something like these {"cms":["1","2","3","4","5"],"product":[false],"static":["contact","sitemap","stores"]} the numeber are the id of the content just change the number {"cms":["2","1","3","4","5"],"product":[false],"static":["contact","sitemap","stores"]} 1 1 Link to comment Share on other sites More sharing options...
Juke29 Posted January 15, 2021 Share Posted January 15, 2021 This is the only solution I know today and we are in 2021. 1 1 Link to comment Share on other sites More sharing options...
Luigi Donato Posted April 22, 2021 Share Posted April 22, 2021 Is a solution.. 😐 1 Link to comment Share on other sites More sharing options...
jfdt Posted September 29, 2021 Share Posted September 29, 2021 Hello. First of all thank you very much for the attention and disinterested help. According to what you have indicated, how should I indicate to display first the categories and then the "product" part:{"1": "new-products", "2": "best-sales"} {"cms":[false],"static":[false],"product":{"1":"new-products","2":"best-sales"},"category":["10","3","9","11","12","6","13","1","15","14"]} Thank you very much Link to comment Share on other sites More sharing options...
chopemp Posted May 29, 2023 Share Posted May 29, 2023 You need to modify the ps_linklist module as below: in modules/ps_linklist/src/Presenter/LinkBlockPresenter.php around line 126, change the makeCmsLinks function as below: /** * @param array $cmsIds * * @return array * * @throws \PrestaShopDatabaseException * @throws \PrestaShopException */ private function makeCmsLinks($cmsIds) { $cmsLinks = []; foreach ($cmsIds as $cmsId) { $cms = new \CMS((int) $cmsId); if (null !== $cms->id && $cms->active) { $cmsLinks[] = [ 'id' => 'link-cms-page-' . $cms->id, 'class' => 'cms-page-link', 'title' => $cms->meta_title[(int) $this->language->id], 'description' => $cms->meta_description[(int) $this->language->id], 'url' => $this->link->getCMSLink($cms), 'position' => $cms->position, ]; } } // Extract the 'position' attribute values into a separate array $positions = array_column($cmsLinks, 'position'); // Sort the array of cmsLinks based on the 'position' attribute array_multisort($positions, $cmsLinks); return $cmsLinks; } This will sort the links according to their "position" attribute. 1 Link to comment Share on other sites More sharing options...
[email protected] Posted August 20 Share Posted August 20 On 5/29/2023 at 10:50 AM, chopemp said: You need to modify the ps_linklist module as below: in modules/ps_linklist/src/Presenter/LinkBlockPresenter.php around line 126, change the makeCmsLinks function as below: /** * @param array $cmsIds * * @return array * * @throws \PrestaShopDatabaseException * @throws \PrestaShopException */ private function makeCmsLinks($cmsIds) { $cmsLinks = []; foreach ($cmsIds as $cmsId) { $cms = new \CMS((int) $cmsId); if (null !== $cms->id && $cms->active) { $cmsLinks[] = [ 'id' => 'link-cms-page-' . $cms->id, 'class' => 'cms-page-link', 'title' => $cms->meta_title[(int) $this->language->id], 'description' => $cms->meta_description[(int) $this->language->id], 'url' => $this->link->getCMSLink($cms), 'position' => $cms->position, ]; } } // Extract the 'position' attribute values into a separate array $positions = array_column($cmsLinks, 'position'); // Sort the array of cmsLinks based on the 'position' attribute array_multisort($positions, $cmsLinks); return $cmsLinks; } This will sort the links according to their "position" attribute. Thnaks chopemp,I have used this method to sort a menu of categories links and it works (with little changes to the code). Is it possible to override the ps_linklist module to make this change immune from Prestashop updates? I tried to put the modified file, using the same path, inside my graphic theme, but it doesn't work. Do you have any idea what I could do? Thank you Link to comment Share on other sites More sharing options...
Mehdi Bourechka Posted August 20 Share Posted August 20 On 6/8/2017 at 1:35 PM, PrestaDesigner10 said: Hello, how can I reorder the links in the the native module "Widget link" (folder module/ps_linklist) I'm using prestashop 1.7.1. Thanks! The module ps_linklist in 1.7.1 doesn’t allow drag-and-drop sorting of links inside a block. Links appear in the order they were created. To change it you either need to recreate the links in the right sequence, adjust them directly in the database, or update to a newer version of the module where link ordering is improved. If the interface still misbehaves, test with the Classic theme and disable other modules to rule out conflicts. 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