URL structure

39 views
Skip to first unread message

Kobe

unread,
Mar 20, 2012, 4:30:55 AM3/20/12
to QuickApps CMS
Hey,

I move a page to QuickApps CMS, but very important for some reason
(SEO) is to maintain my current URL structure. Fortunately, it is very
similar to that in quickapps.

Currently, the addresses are constructed as follows:
http://example.com/article/title-title-title.php

As you can see the only difference is ".php" instead of ".html" at the
end of the address.

How can I change this - of course, preferably in module - without
modifying the core system?

Chris

unread,
Mar 20, 2012, 6:22:15 AM3/20/12
to QuickApps CMS
QuickApps Sites are allowed to define custom URLs by using the file
`Config/routes.php`,

//From Config/routes.php:
/**
* You can use this file to set specific routing rules outside the
QuickApps CMS core,
* so updates won't affect them. Warning: This is for advanced users
only, those with a
* proper understanding of PHP and its' syntax.
*
* NOTE: This file is included after QuickApps CMS routes.php file.
*/

---

So you should write the same route rule used by quickapps cms (located
in QuickApps/Plugin/Node/Config/routes.php) but replace the `html` by
`php`, and you will get this:


Router::connect('/:type/:slug.php', array('plugin' => 'node',
'controller' => 'node', 'action' => 'details'), array('pass' =>
array('type', 'slug')));


Simply write the line above in the mentioned routes.php file and you
are done.


Regards,
Chris

Tomek Kobyliński

unread,
Mar 20, 2012, 6:30:50 AM3/20/12
to quicka...@googlegroups.com
Thank you very much!

By the way, one more question. When I want for the "content type" set a different layout as it properly should be done? Or is it also a possibility for specific documents?
--
http://www.polkobexim.pl

Chris

unread,
Mar 20, 2012, 7:02:21 AM3/20/12
to QuickApps CMS
QuickApps does not include natively that feature, but it can be
achieve in several ways.

1) The most simple (and more limited) is to create a specific theme.
With only one unique layout (default.ctp) and perform a `content-type-
detection` and display different layout depending of content type,
e.g.:

// Themes/Themed/MyTheme/Layouts/default.ctp
<?php if ($this->is('view.node') && $this->Layout->getNodeType() ==
'id-of-your-content-type'): ?>
<html>
<header>
</header>
<body>CONTENT TYPE BASED LAYOUT</body>
</html>
<?php else: ?>
<html>
<header>
</header>
<body>DEFAULT LAYOUT</body>
</html>
<?php endif; ?>

You can automatize this for any content-type, by creating a hook based
detection using you theme's associated module.
(for more info about `associated module` check the wiki)

---

2) Another way (a bit more difficult) is to do the same as before but
in the controller level by using the `beforeRender` callback, you can
define this callback in your theme's associated module Component-hook-
class. e.g.:

// Themes/Themed/MyTheme/app/ThemeMyTheme/Controller/Component/
ThemeMyThemeHookComponent.php

<?php

public function beforeRender() {
if ($this->is('view.node') && $this->Layout['node']['NodeType']
['id'] == 'id-of-your-content-type') {
$this->layout = 'content_type_layout';
}
}

This solution gives you more control over the layout, because you can
modify a lot of things before layout gets rendered.

---

3) And the ultimate solution, is to create a module to manage that
problem, basically it should automatically do the above solution
(controller based).


---

P.S.: Meaby I'll include this feature as native on v1.1

Chris

unread,
Mar 20, 2012, 9:03:15 AM3/20/12
to QuickApps CMS
Was not difficult to include in the core, so here is it:

https://github.com/QuickAppsCMS/QuickApps-CMS/wiki/Theming-Nodes-by-Content-Type

Tomek Kobyliński

unread,
Mar 20, 2012, 9:38:31 AM3/20/12
to quicka...@googlegroups.com
Wow! Thank you very much, really helps me a job.

Regards,

Miah Gregory

unread,
Mar 20, 2012, 1:11:32 PM3/20/12
to quicka...@googlegroups.com
Hi,

Vaguely related to this, is it possible to use slugs without /page/ in
them (eg. http://foo.bar.com/about) out of the box, or does this come
down to setting up custom routes for each page?

--
Regards,

Miah

Geoff Douglas

unread,
Mar 20, 2012, 1:21:07 PM3/20/12
to quicka...@googlegroups.com
It depends on how crazy you want to get with your urls.

If you know that you are always going to use the page controller to handle all root url requests, you can create a wildcard, and direct all urls that match that pattern to the pages controller.
One thing you need to look out for is the sequence of the pattern matching. You need to set it up so that the other patterns (i.e. categories, tags, etc) don't get swallowed up by the root page pattern. 

The other way around it is to create an actual rewrite controller and let that controller match specifc urls, but that is a-whole-nother module. 

Geoff Douglas

Miah Gregory

unread,
Mar 20, 2012, 1:41:52 PM3/20/12
to quicka...@googlegroups.com
Hi Geoff,

Thanks for your reply.

I'll give the wildcard matching a whirl - I did this before with cake
1.x but it didn't give the results I expected, so I wrote a custom
routing class. I may try similar with QA CMS if the wildcard approach
doesn't work for me.

Chris

unread,
Mar 20, 2012, 2:14:03 PM3/20/12
to QuickApps CMS
As Geoff said, you can do anything by creating additional routing
rules.
But what you described before escapes from QA's conventions, and may
produce unexpected behaviors on your site.

I don't know if this may be useful for you:
https://github.com/QuickAppsCMS/QuickApps-CMS/wiki/SiteApp
> On Tue, Mar 20, 2012 at 10:11 AM, Miah Gregory <m...@darksilence.net>
> wrote:
>         Hi,
>
>         Vaguely related to this, is it possible to use slugs
>         without /page/ in
>         them (eg.http://foo.bar.com/about) out of the box, or does this

Geoff Douglas

unread,
Mar 20, 2012, 3:17:22 PM3/20/12
to quicka...@googlegroups.com
I think I have had success doing something like this, but the trick is actually doing the broadest match first, then getting more specific. That way the broad page matching is loaded as a default, then all the other patterns overwrite it.

You may also want to add a 'Not "/"' (obviously in regex) to the slug matching, so that other urls don't get confused.

Please correct me if I am wrong.

Geoff Douglas

Tomek Kobyliński

unread,
Mar 26, 2012, 11:51:43 AM3/26/12
to quicka...@googlegroups.com
it me again;)

there is small (?) error. when you set the layout for a content type; and set page with changed layout as the homepage - it will not work 
(if  you call it as http://example.com/ , of course when link is http://example.com/main/page.html it works)

thanks;)

Chris

unread,
Mar 26, 2012, 12:16:20 PM3/26/12
to QuickApps CMS
Hey!
Are you referring to this?:
https://github.com/QuickAppsCMS/QuickApps-CMS/wiki/Theming-Nodes-by-Content-Type

Remember that this feature allows you "To use different layout for
individual content types".
The Frontpage is not an "individual content type".

---

Are you trying to set `/main/page.html` as homepage by using custom
Routing rules ?
Did you try to set the `Default front page` option in the
`Configuration` section (/admin/system/configuration) instead ?


On 26 mar, 17:51, Tomek Kobyliński <tomek.kobylin...@gmail.com> wrote:
> it me again;)
>
> there is small (?) error. when you set the layout for a content type; and
> set page with changed layout as the homepage - it will not work
> (if  you call it ashttp://example.com/, of course when link ishttp://example.com/main/page.htmlit works)
>
> thanks;)
>
>
>
>
>
>
>
> On Tue, Mar 20, 2012 at 14:03, Chris <y2k2...@gmail.com> wrote:
> > Was not difficult to include in the core, so here is it:
>
> >https://github.com/QuickAppsCMS/QuickApps-CMS/wiki/Theming-Nodes-by-C...

Tomek Kobyliński

unread,
Mar 26, 2012, 12:49:37 PM3/26/12
to quicka...@googlegroups.com
On Mon, Mar 26, 2012 at 18:16, Chris <y2k...@gmail.com> wrote:
Hey!
Are you referring to this?:
https://github.com/QuickAppsCMS/QuickApps-CMS/wiki/Theming-Nodes-by-Content-Type


yes
 
Remember that this feature allows you "To use different layout for
individual content types".
The Frontpage is not an "individual content type".

---

Are you trying to set `/main/page.html` as homepage by using custom
Routing rules ?

no
 
Did you try to set the `Default front page` option in the
`Configuration` section (/admin/system/configuration) instead ?


I did it and it was not working. :(


Chris

unread,
Mar 26, 2012, 1:33:41 PM3/26/12
to QuickApps CMS
Ok,
after a few tests now I see what you mean.

---

Custom-Node-Theme feature does not work when using the `Default front
page` option.


This ocurss because `Default front page` renders the specified page
using requestAction(),
all this is invoked from `NodeControler::index()` which is not a `Node
full page` (or NodeController::details()),
so it is detected by QACMS as a non-node-details request...and as I
said before: Custom-Node-Theme feature works only on `individual
content types` == NodeController::details()

---

A bit difficult to solve this issue but here is a fix that should
work:
https://github.com/QuickAppsCMS/QuickApps-CMS/commit/1d5fa7f542182f66cd5979ead7ca3ea851c8a4b9

On 26 mar, 18:49, Tomek Kobyliński <tomek.kobylin...@gmail.com> wrote:
> On Mon, Mar 26, 2012 at 18:16, Chris <y2k2...@gmail.com> wrote:
> > Hey!
> > Are you referring to this?:
>
> >https://github.com/QuickAppsCMS/QuickApps-CMS/wiki/Theming-Nodes-by-C...

Tomek Kobyliński

unread,
Mar 26, 2012, 1:37:30 PM3/26/12
to quicka...@googlegroups.com
thank you very much. support for quickapps is great;)

2012/3/26 Chris <y2k...@gmail.com>
Reply all
Reply to author
Forward
0 new messages