Implementing a custom statistics module

View: New views
20 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Implementing a custom statistics module

by Nils Breunese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello all,

I'm fairly new to Magnolia and my first project is implementing a custom
statistics module which will be used on all sites we'll develop for the
Magnolia platform we are currently building. I have checked out the
Google Analytics module that is currently being developed, but I have a
feeling that I can't exactly copy its way of doing business.

Our custom statistics work by loading an image (either using JavaScript
or a regular img tag in a noscript tag when JavaScript is not
available). The URL for this image needs some site-specific and some
page-specific information.

I have a few questions about how to implement this functionality:

* I guess I need to add a dialog to every page for the page-specific
statistics metadata. Should I solve that by creating a new tab control
under Dialog Definitions -> generic -> pages?

* Should I add a dialog under Dialog Definitions -> pages -> home ->
stkHomeProperties for the site-specific statistics metadata?

* Where should I plug in the JavaScript and the addition of the
<noscript> tag? In what way would I be able to access the site-specific
and page-specific metadata needed for the JavaScript call? I think I may
need to modify the templates (and maybe implement a custom taglib), but
of course I'd like to hack up the STK as little as possible. I looked at
the Google Analytics module, which uses a processed JavaScript file
(JavaScript with Freemarker markup) backed by a model class. Would I
need to use a similar approach? I was thinking of using the content
variable through Freemarker, but in the processed JavaScript that
variable refers to the JavaScript itself, not the node for which the
JavaScript is loaded so that doesn't really help me find the
page-specific statistics metadata.

Any and all tips, recommendations, examples, etcetera are very welcome.

Nils Breunese.

P.S. I'm currently using Magnolia 4.1.1 Community Edition, but we'll
soon have access to the Enterprise Edition.

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Implementing a custom statistics module

by Nils Breunese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Nils Breunese wrote:

> * Where should I plug in the JavaScript and the addition of the
> <noscript> tag? In what way would I be able to access the site-specific
> and page-specific metadata needed for the JavaScript call? I think I may
> need to modify the templates (and maybe implement a custom taglib), but
> of course I'd like to hack up the STK as little as possible. I looked at
> the Google Analytics module, which uses a processed JavaScript file
> (JavaScript with Freemarker markup) backed by a model class. Would I
> need to use a similar approach? I was thinking of using the content
> variable through Freemarker, but in the processed JavaScript that
> variable refers to the JavaScript itself, not the node for which the
> JavaScript is loaded so that doesn't really help me find the
> page-specific statistics metadata.

A colleague of mine pointed out to me that he found something called
'autoGeneratedParagraph'. Would it make sense to plug something like
that into the global Configuration -> modules -> standard-templating-kit
-> config -> site (default in EE?) -> templates -> prototype tree
somewhere to accomplish this?

Nils Breunese.

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Implementing a custom statistics module

by Matteo Pelucco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Nils Breunese ha scritto:
>
> A colleague of mine pointed out to me that he found something called
> 'autoGeneratedParagraph'. Would it make sense to plug something like
> that into the global Configuration -> modules -> standard-templating-kit
> -> config -> site (default in EE?) -> templates -> prototype tree
> somewhere to accomplish this?

Hi Nils,
it depends on your needs.
An autogenerated paragraph avoid editor to do following ops:

1) click on "new content" green button
2) add DEFAULT value where you want

It can be a good resource for lazy editor and for template-driven
website approach and even for your use-case, if you want to spread your
website with identical paragraphs (1 for page).

I think it is better to implement it like you would implement a header
or a footer. Look at STK header / footer: they are defined once and then
a template render them on every page.
In that template you can of course read also custom page vars and place
inside the javascript.
For including the JS, it depends where the JS should be placed, I
suppose it is an inline JS.
In this case you may want to consider to extend STK templates with an
external freemarker include instruction, that insert your custom template.

Less effort, big results! :-)

But this is how I would do... all depends on you!
HTH, Matteo


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Re: Implementing a custom statistics module

by Nils Breunese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Matteo Pelucco wrote:

> I think it is better to implement it like you would implement a header
> or a footer. Look at STK header / footer: they are defined once and then
> a template render them on every page.
> In that template you can of course read also custom page vars and place
> inside the javascript.
> For including the JS, it depends where the JS should be placed, I
> suppose it is an inline JS.
> In this case you may want to consider to extend STK templates with an
> external freemarker include instruction, that insert your custom template.

This sounds like an interesting approach. As I said, I'm still pretty
new to Magnolia, so I'm not familiar with all possibilities yet.

In my original post I mentioned needing page-specific metadata, but I
realized that I actually meant template-specific metadata. Is there some
place where I can extend all STK templates to include a custom template
that I will add for our statistics?

And how would I set the template-specific metadata (which should be
optional and overrides any site-specific metadata for statistics)?
Dialogs are only connected to pages and paragraphs, right? So we would
need to configure the metadata by adding nodes to the JCR tree? Or by
setting them directly in the templates (create a taglib?)?

I'm still not quite sure where to start. I welcome any suggestions,
pointers, examples, etc.

Nils Breunese.

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Re: Implementing a custom statistics module

by Nils Breunese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Nils Breunese wrote:

> I'm still not quite sure where to start. I welcome any suggestions,
> pointers, examples, etc.

Well, I just started somewhere:

1) I went to Templating Kit -> Site Configuration ->
/templates/prototype and created a new content node with the following
node data:

* editable: false (Boolean)
* enabled: true (Boolean)
* template: /templating-kit/templates/global/sitestat.ftl

2) I went to Templating Kit -> Templates ->
/templating-kit/templates/global and created a new template called
sitestat. I just put '<p>sitestat</p>' in the template for now, for
testing. I also checked the checkbox to enable this template to enable
this new template.

3) I went to Templating Kit -> Templates ->
/templating-kit/templates/main and added this before the closing div
element:

----
[#if def.sitestat.enabled]
     [#include def.sitestat.template]
[/#if]
----

4) I opened the demo project site and got this error message:

----
Expression def.sitestat is undefined on line 69, column 14 in
templating-kit/templates/main.ftl.
----

I guess I'm missing a piece of the puzzle. Am I somewhat on the right track?

Nils Breunese.

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Implementing a custom statistics module

by Matteo Pelucco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Nils Breunese ha scritto:

>
> Nils Breunese wrote:
>
>> I'm still not quite sure where to start. I welcome any suggestions,
>> pointers, examples, etc.
>
> Well, I just started somewhere:
>
> 1) I went to Templating Kit -> Site Configuration ->
> /templates/prototype and created a new content node with the following
> node data:
>
> * editable: false (Boolean)
> * enabled: true (Boolean)
> * template: /templating-kit/templates/global/sitestat.ftl
>
> 2) I went to Templating Kit -> Templates ->
> /templating-kit/templates/global and created a new template called
> sitestat. I just put '<p>sitestat</p>' in the template for now, for
> testing. I also checked the checkbox to enable this template to enable
> this new template.
>
> 3) I went to Templating Kit -> Templates ->
> /templating-kit/templates/main and added this before the closing div
> element:
>
> ----
> [#if def.sitestat.enabled]
>     [#include def.sitestat.template]
> [/#if]
> ----
>
> 4) I opened the demo project site and got this error message:
>
> ----
> Expression def.sitestat is undefined on line 69, column 14 in
> templating-kit/templates/main.ftl.
> ----
>
> I guess I'm missing a piece of the puzzle. Am I somewhat on the right
> track?

The track is right!
But yes, you missed something :-)

*def* is an instance (freemarker bean-wrapper) of
info.magnolia.module.templatingkit.templates.STKTemplate

if you open that class, you can see some getter / setter methods.
one of them is e.g. getMainArea().
This is the reason of mainData node inside template definition in
AdminCentral --> Templating Kit
In freemarker you can say:

${def.mainArea}

So, if you want to proceed, my suggestion is to extend that java class,
deploy it and add it as template class (*class* NodeData, to place
inside each template definition).

BUT there is also another simpler way.

You can add the vars you need extending a dialog.
Simply add a new tab to the STK pageDialog. In that tab you can place
all the variables you need. They will be left empty by default.
In this case, you can avoid to write java code and you will obtain the
same result.


HTH, Matteo









>
> Nils Breunese.
>
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to:
> <user-list-unsubscribe@...>
> ----------------------------------------------------------------
>
>


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Import in Data Module

by Beno-IT :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I am currently working on the import of data from external system (Sharepoint).
I decide to use Data Module for list of items.

I developed the import into the Data module (into a specific Type of content) but my data is not visible in the admin interface.
Here is the code I wrote to generate a node:
      Content subnode = node.createContent(value,DataConsts.MODULE_DATA_CONTENT_NODE_TYPE);
      node.save();
      subnode.createNodeData("name", value);
      subnode.save();

"node" is the parent folder in the data repository.

Can you help me?
Benoit

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Import in Data Module

by Jan Haderka-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


DataConsts.MODULE_DATA_CONTENT_NODE_TYPE is the parent type for the
custom types. You need to use the type you have created for your entries
instead of the super parent.

HTH,
Jan


On Tue, 2009-11-10 at 09:15 +0100, Benoit Segaert wrote:

> I am currently working on the import of data from external system (Sharepoint).
> I decide to use Data Module for list of items.
>
> I developed the import into the Data module (into a specific Type of content) but my data is not visible in the admin interface.
> Here is the code I wrote to generate a node:
>       Content subnode = node.createContent(value,DataConsts.MODULE_DATA_CONTENT_NODE_TYPE);
>       node.save();
>       subnode.createNodeData("name", value);
>       subnode.save();
>
> "node" is the parent folder in the data repository.
>
> Can you help me?
> Benoit
>
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <user-list-unsubscribe@...>
> ----------------------------------------------------------------


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


RE: Import in Data Module

by Beno-IT :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


After some investigation, we found the error in our code:
      Content subnode = node.createContent(value,new ItemType("status");

"status" is the ItemType create in the Data module.

Benoît


-----Original Message-----
From: user-list-owner@... [mailto:user-list-owner@...] On Behalf Of Benoit Segaert
Sent: mardi 10 novembre 2009 9:15
To: Magnolia User-List
Subject: [magnolia-user] Import in Data Module


I am currently working on the import of data from external system (Sharepoint).
I decide to use Data Module for list of items.

I developed the import into the Data module (into a specific Type of content) but my data is not visible in the admin interface.
Here is the code I wrote to generate a node:
      Content subnode = node.createContent(value,DataConsts.MODULE_DATA_CONTENT_NODE_TYPE);
      node.save();
      subnode.createNodeData("name", value);
      subnode.save();

"node" is the parent folder in the data repository.

Can you help me?
Benoit

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Re: Implementing a custom statistics module

by Nils Breunese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Matteo Pelucco wrote:

> BUT there is also another simpler way.
>
> You can add the vars you need extending a dialog.
> Simply add a new tab to the STK pageDialog. In that tab you can place
> all the variables you need. They will be left empty by default.
> In this case, you can avoid to write java code and you will obtain the
> same result.

I also tried this approach (before actually) and I have another round of
questions.

1. For the site-wide statistics settings I added a new tab under
Templating Kit > Dialog Definitions > pages/home/stkHomeProperties. Does
that make sense or would you place a dialog for site-wide settings
elsewhere?

2. Actually, I only created a reference there and created the actual
dialog nodes under /modules/<module-name>/dialogs/tabSitestat. Is that
recommended over putting the tab directly in the STK tree?

3. Should I export both my dialog definition and the reference to that
dialog in the STK to XML and put them in the bootstrap resources folder
for my module? Or can/should that reference be managed by code (in the
version handler, I guess)?

4. The most important question right now: I can set site-wide settings
using this dialog, but where do I put the JavaScript code? This code
should be included in every page and needs to be able to access to these
settings, so I believe I can't put it under Resources >
templating-kit/js/all because there I have no access to
site/page-specific settings. Or am I wrong about that? I would really
appreciate some guidance on this point.

Thanks for your help so far.

Nils Breunese.

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Re: Implementing a custom statistics module

by gregoryjoseph :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Nov 10, 2009, at 11:29 AM, Nils Breunese wrote:

>
> Matteo Pelucco wrote:
>
>> BUT there is also another simpler way.
>> You can add the vars you need extending a dialog.
>> Simply add a new tab to the STK pageDialog. In that tab you can  
>> place all the variables you need. They will be left empty by default.
>> In this case, you can avoid to write java code and you will obtain  
>> the same result.
>
> I also tried this approach (before actually) and I have another  
> round of questions.
>
> 1. For the site-wide statistics settings I added a new tab under  
> Templating Kit > Dialog Definitions > pages/home/stkHomeProperties.  
> Does that make sense or would you place a dialog for site-wide  
> settings elsewhere?
>
> 2. Actually, I only created a reference there and created the actual  
> dialog nodes under /modules/<module-name>/dialogs/tabSitestat. Is  
> that recommended over putting the tab directly in the STK tree?
>
> 3. Should I export both my dialog definition and the reference to  
> that dialog in the STK to XML and put them in the bootstrap  
> resources folder for my module? Or can/should that reference be  
> managed by code (in the version handler, I guess)?
>
> 4. The most important question right now: I can set site-wide  
> settings using this dialog, but where do I put the JavaScript code?  
> This code should be included in every page and needs to be able to  
> access to these settings, so I believe I can't put it under  
> Resources > templating-kit/js/all because there I have no access to  
> site/page-specific settings. Or am I wrong about that? I would  
> really appreciate some guidance on this point.

Simply in the main.ftl ?

>
> Thanks for your help so far.
>
> Nils Breunese.
>
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <user-list-unsubscribe@...>
> ----------------------------------------------------------------


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Implementing a custom statistics module

by Matteo Pelucco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Nils Breunese ha scritto:

>
> Matteo Pelucco wrote:
>
>> BUT there is also another simpler way.
>>
>> You can add the vars you need extending a dialog.
>> Simply add a new tab to the STK pageDialog. In that tab you can place
>> all the variables you need. They will be left empty by default.
>> In this case, you can avoid to write java code and you will obtain the
>> same result.
>
> I also tried this approach (before actually) and I have another round of
> questions.
>
> 1. For the site-wide statistics settings I added a new tab under
> Templating Kit > Dialog Definitions > pages/home/stkHomeProperties. Does
> that make sense or would you place a dialog for site-wide settings
> elsewhere?

The point 2 is a better option, I think...

> 2. Actually, I only created a reference there and created the actual
> dialog nodes under /modules/<module-name>/dialogs/tabSitestat. Is that
> recommended over putting the tab directly in the STK tree?

Just for sharing purpose.
If you intend to use that tab somewhere else, it is a good practice :-)
So you can include it in stkHomeProperties, stkPageProperties, ...

> 3. Should I export both my dialog definition and the reference to that
> dialog in the STK to XML and put them in the bootstrap resources folder
> for my module? Or can/should that reference be managed by code (in the
> version handler, I guess)?

Bootstrap, of course.
And also version handler for future versions!

> 4. The most important question right now: I can set site-wide settings
> using this dialog, but where do I put the JavaScript code? This code
> should be included in every page and needs to be able to access to these
> settings, so I believe I can't put it under Resources >
> templating-kit/js/all because there I have no access to
> site/page-specific settings. Or am I wrong about that? I would really
> appreciate some guidance on this point.

I think, as Gregory suggested, that you can extend STK main.ftl
including a custom template.

Otherwise you can use the theme capabilities to include extra CSS and
extra JS in headerHTML. Try to extend the POP theme in this way...

HTH,
M.


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Implementing a custom statistics module

by Matteo Pelucco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Nils Breunese ha scritto:
 >
 > Matteo Pelucco wrote:
 >
 >> BUT there is also another simpler way.
 >>
 >> You can add the vars you need extending a dialog.
 >> Simply add a new tab to the STK pageDialog. In that tab you can place
 >> all the variables you need. They will be left empty by default.
 >> In this case, you can avoid to write java code and you will obtain the
 >> same result.
 >
 > I also tried this approach (before actually) and I have another round of
 > questions.
 >
 > 1. For the site-wide statistics settings I added a new tab under
 > Templating Kit > Dialog Definitions > pages/home/stkHomeProperties. Does
 > that make sense or would you place a dialog for site-wide settings
 > elsewhere?

The point 2 is a better option, I think...

 > 2. Actually, I only created a reference there and created the actual
 > dialog nodes under /modules/<module-name>/dialogs/tabSitestat. Is that
 > recommended over putting the tab directly in the STK tree?

Just for sharing purpose.
If you intend to use that tab somewhere else, it is a good practice :-)
So you can include it in stkHomeProperties, stkPageProperties, ...

 > 3. Should I export both my dialog definition and the reference to that
 > dialog in the STK to XML and put them in the bootstrap resources folder
 > for my module? Or can/should that reference be managed by code (in the
 > version handler, I guess)?

Bootstrap, of course.
And also version handler for future versions!

 > 4. The most important question right now: I can set site-wide settings
 > using this dialog, but where do I put the JavaScript code? This code
 > should be included in every page and needs to be able to access to these
 > settings, so I believe I can't put it under Resources >
 > templating-kit/js/all because there I have no access to
 > site/page-specific settings. Or am I wrong about that? I would really
 > appreciate some guidance on this point.

I think, as Gregory suggested, that you can extend STK main.ftl
including a custom template.

Otherwise you can use the theme capabilities to include extra CSS and
extra JS in headerHTML. Try to extend the POP theme in this way...

HTH,
M.


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Re: Implementing a custom statistics module

by Nils Breunese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Grégory Joseph wrote:

> On Nov 10, 2009, at 11:29 AM, Nils Breunese wrote:
>> 4. The most important question right now: I can set site-wide  
>> settings using this dialog, but where do I put the JavaScript code?  
>> This code should be included in every page and needs to be able to  
>> access to these settings, so I believe I can't put it under  
>> Resources > templating-kit/js/all because there I have no access to  
>> site/page-specific settings. Or am I wrong about that? I would  
>> really appreciate some guidance on this point.
>
> Simply in the main.ftl ?

Yes, this is possible, but this means my statistics module will modify
main.ftl (or footer.ftl, so some other core template). This is what I
did now and it works, but what if another module also wants to insert a
template by modifying the same template? Only one module can have its
way then.

I guess that in that case I might need to create a module that includes
templates from a specific location in the tree in a specific template
and then have those template-modifying modules depend on that module or
something. For now I'll just let my statistics module override main.ftl.

Nils Breunese.

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Re: Implementing a custom statistics module

by Nils Breunese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Matteo Pelucco wrote:

> Nils Breunese ha scritto:
>> Matteo Pelucco wrote:
>>
>>> BUT there is also another simpler way.
>>>
>>> You can add the vars you need extending a dialog.
>>> Simply add a new tab to the STK pageDialog. In that tab you can place
>>> all the variables you need. They will be left empty by default.
>>> In this case, you can avoid to write java code and you will obtain the
>>> same result.
>> I also tried this approach (before actually) and I have another round of
>> questions.
>>
>> 1. For the site-wide statistics settings I added a new tab under
>> Templating Kit > Dialog Definitions > pages/home/stkHomeProperties. Does
>> that make sense or would you place a dialog for site-wide settings
>> elsewhere?
>
> The point 2 is a better option, I think...

What do you mean exactly?

>> 2. Actually, I only created a reference there and created the actual
>> dialog nodes under /modules/<module-name>/dialogs/tabSitestat. Is that
>> recommended over putting the tab directly in the STK tree?
>
> Just for sharing purpose.
> If you intend to use that tab somewhere else, it is a good practice :-)
> So you can include it in stkHomeProperties, stkPageProperties, ...

The dialog is for site-wide settings, so I don't intend to use that tab
anywhere else but under stkHomeProperties. I guess it doesn't really
matter then.

>> 4. The most important question right now: I can set site-wide settings
>> using this dialog, but where do I put the JavaScript code? This code
>> should be included in every page and needs to be able to access to these
>> settings, so I believe I can't put it under Resources >
>> templating-kit/js/all because there I have no access to
>> site/page-specific settings. Or am I wrong about that? I would really
>> appreciate some guidance on this point.
>
> I think, as Gregory suggested, that you can extend STK main.ftl
> including a custom template.

Extend? You mean replace main.ftl with a version that includes my custom
template? That's what I did for now, and that works. But it feels dirty.

Nils Breunese.

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Re: Implementing a custom statistics module

by Nils Breunese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Grégory Joseph wrote:

> Simply in the main.ftl ?

Ok, so my module has two parts now.

1. A dialog tab under stkHomeProperties which allows editing the
site-wide settings for statistics.
2. A custom FreeMarker template that is included in the main.ftl.

Now all I need to connect these two. I want to access the properties
that are saved by the dialog in my FreeMarker template. How do I get to
these properties from a random page on the website? I found I can use
content?parent to access a parent node, but how would I get a reference
to the home content node for any subpage?

For the homepage:
* content?node_type is mgnl:content
* content?parent?node_type is rep:root

But of course I should be able to access the home node from any
arbitarily nested page to get this to work. Can I create some kind of
while loop to walk up the tree? Or is there another way? Or am I just
storing the site-wide settings in the wrong place?

Nils Breunese.

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Implementing a custom statistics module

by Matteo Pelucco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Nils Breunese ha scritto:
>
>>> 1. For the site-wide statistics settings I added a new tab under
>>> Templating Kit > Dialog Definitions > pages/home/stkHomeProperties.
>>> Does that make sense or would you place a dialog for site-wide
>>> settings elsewhere?
>>
>> The point 2 is a better option, I think...
>
> What do you mean exactly?

I would like to say that you can define global configuration and page
configuration. If no page configuration is found, a global is taken. In
this case you are more flexible.
Of course, only if your statistics engine / service let you do so...

>>> 2. Actually, I only created a reference there and created the actual
>>> dialog nodes under /modules/<module-name>/dialogs/tabSitestat. Is
>>> that recommended over putting the tab directly in the STK tree?
>>
>> Just for sharing purpose.
>> If you intend to use that tab somewhere else, it is a good practice :-)
>> So you can include it in stkHomeProperties, stkPageProperties, ...
>
> The dialog is for site-wide settings, so I don't intend to use that tab
> anywhere else but under stkHomeProperties. I guess it doesn't really
> matter then.

As I said, it depends on you :-)

>> I think, as Gregory suggested, that you can extend STK main.ftl
>> including a custom template.
>
> Extend? You mean replace main.ftl with a version that includes my custom
> template? That's what I did for now, and that works. But it feels dirty.

This is one option.
STK default implementation doesn't let you define a custom httpHeader,
so you can use theme capabilities of including CSS / JS (simply defining
them) or you can extends FTL templates with your own.

I think no other easy roads are possible.
matteo


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Re: Implementing a custom statistics module

by Nils Breunese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Matteo Pelucco wrote:

> Nils Breunese ha scritto:
>>>> 1. For the site-wide statistics settings I added a new tab under
>>>> Templating Kit > Dialog Definitions > pages/home/stkHomeProperties.
>>>> Does that make sense or would you place a dialog for site-wide
>>>> settings elsewhere?
>>> The point 2 is a better option, I think...
>> What do you mean exactly?
>
> I would like to say that you can define global configuration and page
> configuration. If no page configuration is found, a global is taken. In
> this case you are more flexible.
> Of course, only if your statistics engine / service let you do so...

The requirement for page-specific settings has been dropped for now, so
that's been taken care of. But I haven't figured out how to access the
site-wide properties that are stored under the home page from an
arbitrarily nested subpage. How would you do this?

I'd have to know how many levels I need to go up to reach the home page
or run some kind of while loop that accesses the parent until I've
reached the home page which has the site-side properties. It seems there
are utility functions for node children, not not any (recursive) parent
functions. Am I missing something here?

>>> I think, as Gregory suggested, that you can extend STK main.ftl
>>> including a custom template.
>> Extend? You mean replace main.ftl with a version that includes my custom
>> template? That's what I did for now, and that works. But it feels dirty.
>
> This is one option.
> STK default implementation doesn't let you define a custom httpHeader,
> so you can use theme capabilities of including CSS / JS (simply defining
> them) or you can extends FTL templates with your own.

I'd like this module to be independent from any themes, so I guess I'll
stay on the track of extending the main.ftl.

> I think no other easy roads are possible.

Ok, thanks for thinking along.

Nils Breunese.

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Implementing a custom statistics module

by Matteo Pelucco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Nils Breunese ha scritto:
>
> But I haven't figured out how to access the
> site-wide properties that are stored under the home page from an
> arbitrarily nested subpage. How would you do this?

Look for header and footer ftl. They use paragraphs defined only in main
page.

> I'd like this module to be independent from any themes, so I guess I'll
> stay on the track of extending the main.ftl.

Ok, it is a good choice, I think..

Cheers
Matteo


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Re: Implementing a custom statistics module

by Nils Breunese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Matteo Pelucco wrote:

> Nils Breunese ha scritto:
>> But I haven't figured out how to access the
>> site-wide properties that are stored under the home page from an
>> arbitrarily nested subpage. How would you do this?
>
> Look for header and footer ftl. They use paragraphs defined only in main
> page.

I'm not sure exactly what you mean. Right now I have no paragraphs in my
module and I wasn't planning on using any. I wanted to use the
?ancestors built-in in FreeMarker to get to the home page and then read
the statistics properties from that node, but using ?ancestors gives me
an error (see my separate post about this problem). Isn't that a good
solution?

Nils Breunese.

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------

< Prev | 1 - 2 | Next >