Application / custom module integration on page-cms

1 view
Skip to first unread message

JL

unread,
Apr 8, 2009, 6:19:50 AM4/8/09
to django-page-cms
Hi everyone.

I'm using page-cms on django and it's excellent. But now I would like
to have a custom made application shown on a page created by page-cms.
Is this possible and how should I do it? I mean: I have this news
application which works with /news/... etc urls. It list news and
displays details of them etc. Very simple. But how can I integrate
this module into a page?

I tried to create a new page with slug 'news' and that link gave me
the correct app in a public site. But it should also work with slugs
and should have the navigation also. It would be cool to just choose
one of the installed applications from the dropdown when creating a
new page in admin site and then instead of a normal content the page
shows this module/application.

All help/ideas/suggestions are very welcome, thanks.

I tried to solve this myself but haven't succeeded yet. My idea was to
create a Moduledispatcher application that maps the slug into the
modules. It is the first one in the urlpattern list. It has a table
with modulename and slugname fields, so when the page is created and,
lets say, the news module choosen and 'LatestNews' for example as the
slug, there would be a row with modulename=news and
slugname=LatestNews. So when the user navigates to /LatestNews/, this
dispatcher kind of redirects it to this news module. If there is no
row on that dispatcher table with the given slug, it shows the page
normally as with page-cms.

Does anyone follow me this far? :D So this is the point I'm stuck. I
don't know how to implement this redirection of urls in dispatcher.
Can anyone help with this? Could be useful to a lot of people.

Thanks!

/ Joni

Batiste Bieler

unread,
Apr 8, 2009, 6:29:39 AM4/8/09
to django-...@googlegroups.com
Hello,

For integrating this CMS with 3rd party apps there this rough and
simple app connection feature :

http://code.google.com/p/django-page-cms/wiki/3thPartyApps

But it definitely need some working to be more useful. I don't if it's
the path you want to follow...
Can you make some sketch, or a use case of what the user would expect
when a "News" page is created?

An idea: Each news could have a page ForeigneKey, you can create your
news with your news app and liken them to some pages. Then you adapt
your view to get the new and display them in the template? What do you
think about that? What can we do in a better way?

JL

unread,
Apr 8, 2009, 6:47:48 AM4/8/09
to django-page-cms
Thanks for your answer Batiste!

But that's not exactly what I'm looking for. The basic idea is that
admin can add a custom application anywhere on the page-tree. Instead
of the content user can write with page-cms' wysiwyg editor, the page
shows the content created by that chosen application.

For example:
My news application's urls.py looks like this:

urlpatterns = patterns('',
(r'^$', 'news.views.Listnews'),
(r'^(?P<year>\d+)/$', 'news.views.ShowYear'),
(r'^(?P<year>\d+)/(?P<month>\d+)/$', 'news.views.ShowMonth'),
(r'^(?P<year>\d+)/(?P<month>\d+)/(?P<day>\d+)/$',
'news.views.ShowDay'),
(r'^(?P<year>\d+)/(?P<month>\d+)/(?P<day>\d+)/(?P<title>[A-Za-z]
+)/$', 'news.views.ShowDetails'),
)

So when navigated to ie '/news/2009/4/' this application shows the
news created in april 2009. '/news/2009/4/8/Coding' would show the
news which has a title 'Coding' and it was created 8.4.2009 etc etc.

This is basics, understood this far? Ok, so..

When the admin creates a new page, he chooses this news application
from the dropdown and chooses to write LatestNews for slug. So when he
navigated '/LatestNews/', the public site would have all the
navigation menu etc the same, but instead of normal written content,
it shows the content created by 'news/' but '/LatestNews/' stays in
the url. Ok? And so on, '/LatestNews/2009/4/' shows the news created
on april in the content area on the template.

/ Joni




On 8 huhti, 13:29, Batiste Bieler <batiste.bie...@gmail.com> wrote:
> Hello,
>
> For integrating this CMS with 3rd party apps there this rough and
> simple app connection feature :
>
> http://code.google.com/p/django-page-cms/wiki/3thPartyApps
>
> But it definitely need some working to be more useful. I don't if it's
> the path you want to follow...
> Can you make some sketch, or a use case of what the user would expect
> when a "News" page is created?
>
> An idea: Each news could have a page ForeigneKey, you can create your
> news with your news app and liken them to some pages. Then you adapt
> your view to get the new and display them in the template? What do you
> think about that? What can we do in a better way?
>

JL

unread,
Apr 8, 2009, 6:53:18 AM4/8/09
to django-page-cms
Is it possible somehow to dynamically create urlpatterns?

I mean if I have this dispatcher which says for example that
LatestNews slug means our news application, Can I somehow create this
news.py's urlpatterns dynamically having news replaced by LatestNews?

Batiste Bieler

unread,
Apr 8, 2009, 7:18:16 AM4/8/09
to django-...@googlegroups.com
Completely dynamically I guess it's not that easy... But it should be possible.

Some clue : http://www.artfulcode.net/articles/dynamic-urls-django/


2009/4/8 JL <lehto...@gmail.com>:

JL

unread,
Apr 8, 2009, 8:19:01 AM4/8/09
to django-page-cms
How can I pass the request forward in this situation:

Admin has created page with 'LatestNews' as slug and chosen news
module for the page.
This is the mapping table:
class Module(models.Model):
modulename = models.CharField(max_length=100)
slugname = models.CharField(max_length=100)

and my dispatchers urls has this:
url(r'^.*?/?(?P<slug>[-\w]+)/$',
'moduledispatcher.views.dispatch'),

So all the urls goes first to the dispatch method:

def dispatch(request, slug):
module = Module.objects.get(slugname=slug)
# TODO!


So in the TODO part I have module.modulename which is the real module.
In that 'LatestNews/' case modulename is news. How can I pass that
request to that news module in that TODO point?

JL

unread,
Apr 8, 2009, 9:12:00 AM4/8/09
to django-page-cms
Actually I think this should be done so that in pages 'details' method
I check if there is a module for the given slug before page-cms gets
the page. And if module is defined, then pass the request to that
application, and if not then continue with page-cms code. How to do
that is an other thing :)

/ Joni

Batiste Bieler

unread,
Apr 8, 2009, 11:49:29 AM4/8/09
to django-...@googlegroups.com
It seems interesting, I will be interested by a patch when everything
will be up and running.

2009/4/8 JL <lehto...@gmail.com>:

JL

unread,
Apr 9, 2009, 3:21:04 AM4/9/09
to django-page-cms
Is there any way to call certain applications view from other
applications view (with current request)?

/ Joni


On 8 huhti, 18:49, Batiste Bieler <batiste.bie...@gmail.com> wrote:
> It seems interesting, I will be interested by a patch when everything
> will be up and running.
>
> 2009/4/8 JL <lehto.j...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages