Developer
Supported
Router
ExpressionEngine 2
Back to this add-on's main page
View Other Add-ons From Isaac Raway
[Resolved] Removing segments and compatibility
General (Resolved)
Djive
|
Posted: 20 October 2015 08:58 AM |
|
|
|
Hi
I need to shorten URL-s of entries on site, remove template segments from a URL.
Example 1:
URL: domain.com/blog-template/detailed/entry-post (entry - full post)
I need to look this URL: domain.com/entry-post (I still need to see full post)
But if i visit URL: domain.com/blog-template (I need to be able to see all posts as before)
I tried with several add-ons and because of EE structure I get a 404 error page.
Is this possible to achive with Router.
Notable addons that we are using:
Expresso Store https://www.exp-resso.com/
Low search https://devot-ee.com/add-ons/low-search
GWcode Categories http://gwcode.com/add-ons/gwcode-categories
Mobile https://devot-ee.com/add-ons/mobile
Is Router compatible with those addons?
Thank You
|
|
|
MetaSushi
|
Posted: 20 October 2015 10:24 AM |
# 1
|
|
Developer
|
It should be possible to do something like this. You would need to, roughly:
1. Move your site/index template to a new template such as site/home.
2. In site/index, place the call to Router. Be sure to pass the new site/home template as the 404 template to Router’s tag.
2. Disable Strict URLs.
3. Move the logic from blog-template/detailed to a new template to be embedded such as blog-template/_detail_embed
4. Embed _detail_embed in blog-template/detailed, passing in {segment_3} as an embed parameter
5. Create a route in routes.ini that triggers blog-template/_detail_embed, also passing in the same embed parameter
Do not do any of this directly on a live server, only do it on a development server, then test your site carefully before pushing to your production/live server.
|
|
|
Djive
|
Posted: 28 October 2015 10:05 AM |
# 2
|
|
|
Hi, i tried but can not make it work.
Can you write exact steps and code?
I did the first three steps
1. Move your site/index template to a new template such as site/home.
2. In site/index, place the call to Router. Be sure to pass the new site/home template as the 404 template to Router’s tag. ({exp:router:route no_route=“site/home”})
3. Disable Strict URLs.
Here is the example:
http://hrvojeproluft.wmd-flash.com/najam-aparata-isusivanje-vlage/cijena/zasto-isusivanje-odvlazivacima
should be:
http://hrvojeproluft.wmd-flash.com/zasto-isusivanje-odvlazivacima
In attachement is “najam-aparata-isusivanje-vlage/cijena” template code.
Please write request.ini code and other neccessary code for templates that are needed.
Thanks
File Attachments
|
|
|
MetaSushi
|
Posted: 28 October 2015 02:28 PM |
# 3
|
|
Developer
|
If the instructions are unclear I’ll be happy to clarify anything if you can ask specific questions, but our free support service does not include writing template code on your behalf. As far as the routes.ini file goes, the example on the product’s main page is almost exactly what you’re asking for. The “# main section” section of the sample ini file matches any URL slug and passes control to a template.
[defaults] cat1 = cat2 = url_title = club = year = 0 month = 0 day = 0
[routes] ## ## home ## ^/*$ = "site/_home"
## ## normal sections ##
# main section ^(?P<cat1>.+)/*$ = "sections/_section" categories="{router_cat1_category_id}" title="{router_cat1_category_name}"
# main section month archive ^(?P<cat1>.+)/(?P<year>\d+)/(?P<month>\d+)/*$ = "sections/_section" categories="{router_cat1_category_id}" title="{router_cat1_category_name}"
# main section day archive ^(?P<cat1>.+)/(?P<year>\d+)/(?P<month>\d+)/(?P<day>\d+)/*$ = "sections/_section" categories="{router_cat1_category_id}" title="{router_cat1_category_name}"
# main section post ^(?P<cat1>.+)/(?P<year>\d+)/(?P<month>\d+)/(?P<day>\d+)/(?P<url_title>.+)/*$ = "posts/_detail" categories="{router_cat1_category_id}"
## ## better workflow preview ## ^posts/preview/(?P<entry_id>\d+)/*$ = "posts/_detail"
|
|
|
Djive
|
Posted: 02 November 2015 06:51 AM |
# 4
|
|
|
Hi, here is my .ini file:
[defaults] url_title=
[routes]
## ## home ## ^/*$ = "site/home"
^(?P<url_title>.+)/*$ = "najam-aparata-isusivanje-vlage/_cijena_embed"
in “najam-aparata-isusivanje-vlage/cijena” i have:
{embed="najam-aparata-isusivanje-vlage/_cijena_embed" kaj="{segment_3}"}
and in “najam-aparata-isusivanje-vlage/_cijena_embed” i have:
{exp:channel:entries channel="najam-aparata-isusivanje-vlage" url_title="{embed:kaj}"} {title} {/exp:channel:entries}
but i always get 404 page.
Can you tell me what is wrong in my code, thanks.
|
|
|
|
Djive
|
Posted: 02 November 2015 11:49 AM |
# 6
|
|
|
Default template group index is:
{exp:router:route no_route="site/home"}
Strict URLs are disabeled.
|
|
|
MetaSushi
|
Posted: 02 November 2015 12:33 PM |
# 7
|
|
Developer
|
Ah, just noticed that the routes.ini file doesn’t have the embed parameter. You still need to pass in kaj=”” value to the embed, something like this should work:
[defaults] url_title=
[routes]
## ## home ## ^/*$ = "site/home"
^(?P<url_title>.+)/*$ = "najam-aparata-isusivanje-vlage/_cijena_embed" kaj="{router_url_title}"
Also please enable template debugging and reply with the Template Debugger output. There should be a few lines from the Router plugin telling us what’s going on.
|
|
|
Djive
|
Posted: 02 November 2015 03:42 PM |
# 8
|
|
|
It is working now, thanks.
|
|
|
MetaSushi
|
Posted: 02 November 2015 03:46 PM |
# 9
|
|
Developer
|
No problem! I’ll go ahead and close this thread since it’s resolved. Please post again if you have any further questions.
|
|
|