SOLVED Plugin dev. routing - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16) +--- Thread: SOLVED Plugin dev. routing (/showthread.php?tid=8701) |
Plugin dev. routing - mica - 2016-09-06 Hello there! I'm trying to extend an existing plugin (ExtraGallery). to make a specific portfolio. For now, succeed to every modifications I made. But I'm stuck to basic routing problem : How to create a route that use a specific template via http://website.com/gallery/galSlug/ or http://website.com/?gallery=galSlug The original plugin provide a function to retrieve all galleries or a single (via parameter) Do you have some exemple of routing (other plugins e.g) where I can understand how to do that ? Thanks in advance. mica RE: Plugin dev. routing - shawn_a - 2016-09-06 Is gallery your page id ? eg. website.com?id=gallery RE: Plugin dev. routing - mica - 2016-09-06 (2016-09-06, 23:48:31)shawn_a Wrote: Is gallery your page id ? Hi Shawn Nope, for now the plugin doesn't create pages RE: Plugin dev. routing - shawn_a - 2016-09-07 ok so the plugin is already doing its own routing parsing. hmm RE: Plugin dev. routing - mica - 2016-09-07 (2016-09-07, 00:38:00)shawn_a Wrote: ok so the plugin is already doing its own routing parsing. mhmmm no, this is my question, the plugin provide only a function to retrieve gallery So I need to know how to implement the routing Is there any other plugin that make routes? Thanks in advance RE: Plugin dev. routing - shawn_a - 2016-09-07 I do not think there is. I think there is code floating around the forum though. eg http://get-simple.info/forums/showthread.php?tid=8254 RE: Plugin dev. routing - mica - 2016-09-07 (2016-09-07, 01:09:59)shawn_a Wrote: I do not think there is. I think there is code floating around the forum though. Ok thanks a lot, it seems that it's exactly I needed but after many attempts I still have 404 Original pages work http://localhost/siegen/about √ but http://localhost/siegen/projet/abc = 404 X here are some info about my config fancy url are on && (cache flushed many times) no custom permalink specified in the Extra Router GS FRONT ROUTER plugin setting page Route : SITEURL/projet/([a-z0-9-]+) Action : PHP Code: <?php And finally (I think the problem is here) my .htaccess rewrite content Code: RewriteEngine on Could you help me, please ? RE: Plugin dev. routing - shawn_a - 2016-09-07 did you try gs-front-router I linked That plugin you linked asks to change the rewrite rules, which is not necessary, and confusing. RE: Plugin dev. routing - shawn_a - 2016-09-07 actually I wouldn't recommend that one either now that i look at it. Looks buggy. RE: Plugin dev. routing - Bigin - 2016-09-07 Create new route: galleries/([a-z0-9-/]+) in gs-front-router, for example Action: Code: <?php http://mysite/galleries/abc/ http://mysite/galleries/def/ everything working RE: Plugin dev. routing - shawn_a - 2016-09-07 That plugin uses namespaces and anonymous functions closures, so you might have problems on php 5.2 other than that it seems to work well, it will also not work with 3.4 without modification. RE: Plugin dev. routing - mica - 2016-09-07 (2016-09-07, 04:22:53)Bigin Wrote: Create new route: galleries/([a-z0-9-/]+) in gs-front-router, for example Thanks Bigin, it start working I got The Title but the content is empty and when I try 'title' => 'My Title'.$slug, I got only My Title, And of course I need this $slug here is my action code PHP Code: <?php Thanks in advance to both of you guys RE: Plugin dev. routing - mica - 2016-09-07 (2016-09-07, 04:49:15)shawn_a Wrote: That plugin uses namespaces and anonymous functions closures, so you might have problems on php 5.2 Yep, I've some problems even in php 5.6 (GS3.3) with the solution of Bigin : the title work but like the 'content' => doesn't show anything. But this feature (routing) is important for plugins development, don't you think ? Is there another solution to show my galleries ? I can dynamically generate a page with a component each time a gallery is created/saved but I found this way a messy and also hard to maintain. RE: Plugin dev. routing - Bigin - 2016-09-07 put $slug = get_page_slug(false); in your functions.php file in theme directory. Or you can use get_page_slug(false) in your anonymous functions RE: Plugin dev. routing - mica - 2016-09-07 (2016-09-07, 05:20:28)Bigin Wrote: put $slug = get_page_slug(false); in your functions.php file in theme directory. Or you can use get_page_slug(false) in your anonymous functions nope ;( both doesn't work. It looks like 'content' table key change in my version (3.3.11) ? RE: Plugin dev. routing - Bigin - 2016-09-07 (2016-09-07, 05:24:33)mica Wrote:(2016-09-07, 05:20:28)Bigin Wrote: put $slug = get_page_slug(false); in your functions.php file in theme directory. Or you can use get_page_slug(false) in your anonymous functions Turn debug on in your config.php file, to see messages: define('GSDEBUG', TRUE); RE: Plugin dev. routing - mica - 2016-09-07 (2016-09-07, 05:28:37)Bigin Wrote: Turn debug on in your config.php file, to see messages: Already done √ No messages ;( do you have the same version 3.3.11 ? Plugin gs-front-router (latest from github v0.3) ? RE: Plugin dev. routing - Bigin - 2016-09-07 (2016-09-07, 05:31:42)mica Wrote: do you have the same version 3.3.11 ? Plugin gs-front-router (latest from github v0.3) ? GS 3.3.8 Plugin 0.3 RE: Plugin dev. routing - Bigin - 2016-09-07 Are you use get_page_content(); in your theme? RE: Plugin dev. routing - mica - 2016-09-07 (2016-09-07, 06:03:02)Bigin Wrote: Are you use get_page_content(); in your theme? Yep ; ) Ok guys I made a fresh install and the solution of Bigin works there. Probably too much plugins added/removed on my local version here is the final code route : galleries/([a-z0-9-/]+) action : PHP Code: <?php Thank you to both of you for your time and the sharing of your knowledge ! RE: Plugin dev. routing - shawn_a - 2016-09-07 Not sure why he is using a callback for content, there, very confusing. Plugin is also setting data_index after all the globals are set so it is pretty much useless. If you want to set all your variables you need to set globals, you can also just echo your content, since the plugin is also doing a ob_get_contents ( it looks like you can match a bunch of routes and it aggregates all the content togather ) but this does not actually work atm, because he is only using data_index->content not global $content.. I honestly have no idea how the above code even works, it only works because of references which is bad. so as long as you understand these problems it works well. personally id stick with the globals. PHP Code: <?php |