Forums / Setup & design / Main Page

Main Page

Author Message

Sao Tavi

Wednesday 16 March 2011 7:18:32 am

After a long wait I eventualy started building my first project with EZ Publish. I am still learning about the basic features of the system, so please don't expect me to know too much about it.

So, I want to create some special features for the main page. So, in the content area of the main page I want to have 2 blocks, one with the latest news (with some js that will control the output based on some clicks) and one that will run a local linux program and output some results (it's a graph that gets updated every minute).

How do I do that? How do I insert in the content area of the main page these 2 blocks? (everything *is* ready in php more or less, I just need to know how to add them).

Sao Tavi

Wednesday 16 March 2011 10:14:18 am

So, looking around I just found that one way is to create a new class, create a template for how it should look as embedded (so that I can insert it in the content area), create an extension that should control what that class will do when embedded.

Did I got this right? Is this the way to do what I want? Is there other way? What is the recommended approach?

Sao Tavi

Thursday 17 March 2011 3:37:39 am

One other way is to create a special class only for the main page (the template operators are quite powerful) and just use an {include file:..}

My only question now is how to change a page from a class to another, as I need to do this for the main page and I don't want to have to post again all the child pages (I have a main page that includes several main pages - that should latter be changed some other classes -, each of them having content).

But as the previous question remained unanswered, although it would have taken 10 minutes (at most) to read and reply, I have little hope of getting an answer to this.

Later: I found a page that says that this is not possible... Cool, then just delete all and repost. Next time I know.

Marko Žmak

Thursday 17 March 2011 7:05:22 am

Hi Sao, here are some answers that might help...

The best way to display the latest news on the frontpage is like this:

  • create a class Frontpage
  • create an object of that class
  • set the ini setting IndexPage to the content/view/full of this new created object
  • in your design folder create a template override for the full view of the Frontpage class. See the content/view/*.tpl sections in the Template override docs, and the examples on the bottom
  • in the override template for the Frontpage class put the HTML that your frontpage should have
  • in the same template fetch the latest news using content/tree template fetch function (you'll get an array of ezcontentobjecttreenode) and display it where they should be (see foreach)

And remember to clear the cache if you don't see any changes.

As for the inclusion of the graph generated by the linux program I suggest this:

  • make your linux program output the picture in your design folder in the "images" subfolder
  • in the template override for Frontpage, hard link an <img> tag to show the image from that file

I would also suggest you to read the eZP Documentation, especially this parts:

  • http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Concepts-and-basics
  • http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Templates

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Sao Tavi

Sunday 20 March 2011 8:51:25 am

Thank you for your answer.

One more question: I want to fetch all the new pages from a specific node, excepting the ones from a specific subbranch.

How to I do that? How do I exclude from fetching one specific branch?

Marko Žmak

Sunday 20 March 2011 1:56:29 pm

"

Thank you for your answer.

One more question: I want to fetch all the new pages from a specific node, excepting the ones from a specific subbranch.

How to I do that? How do I exclude from fetching one specific branch?

"

As far as I know, there's not a mechanism in the fetch function to exclude a subtree. There is a parameter "exclude_object_ids", but you have to specify the object ids of ALL the object you want to exclude, and not only their parents.

But one sollution would be to fetch only the pages from the specific nodes. Something like this...

Let's say you have this content structure:

 - News (node_id: 10)
   - Economy (node_id: 11)
   - Politics (node_id: 12)
   - Sport (node_id: 13)
   - Old news (node_id: 14)

and that you want to fetch all the articles from "News" except the ones from "Old news".

To get that you would do a fetch that gets all the articles from "Economy", "Politics" and "Sport" like this:

{def $news_items=fetch(content, tree, hash(
 parent_node_id, array(11, 12, 13),
 class_filter_type=include,
 class_filter_array=array(article)
))
}

Hope it helps.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth