Blog snippet on homepage

Author Message

Brian Henkel

Wednesday 16 April 2008 2:38:51 pm

I have a blog and was hoping to showcase a snippet of my latest blog post on the homepage. I added the blog post object to the homepage, but of course, it presents the entire post on the homepage (making the page very long). Can someone please tell me how I can do this, but show only a snippet (first five lines of post) on my homepage? Thanks in advance!

Maxime Thomas

Wednesday 16 April 2008 11:33:55 pm

Hi,

I think you can :
- look at the template called in the homepage
- make an override for this one
- use one this operators (shorten or extract_left):

http://ez.no/doc/ez_publish/technical_manual/4_0/reference/template_operators/strings

Hope it helps.

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Peter Putzer

Thursday 17 April 2008 2:03:57 am

Better yet, use the "teaser" operator provided by the xmlwash package, availabel at http://projects.ez.no/xmlwash. It can be seen in action on http://pluspunkt.at (the thumbnail images are also automatically extracted from the blog posts!).

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

Maxime Thomas

Thursday 17 April 2008 10:50:11 pm

Or you can try to make a new view. It's more in the ez way, I guess :-D

http://ez.no/doc/ez_publish/technical_manual/4_0/reference/template_override_conditions

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Brian Henkel

Monday 12 May 2008 6:03:27 pm

I created an override for my frontpage.tpl file. So how do I use an operator to only display a small portion of the blog post? I'm assuming I have to put something here (in frontpage.tpl) where the blog post is being displayed.

<div class="right-column-position">
            <div class="right-column">
            <!-- Content: START -->
                  {attribute_view_gui attribute=$node.object.data_map.right_column}
            <!-- Content: END -->
            </div>
        </div>

THANKS!

Maxime Thomas

Monday 12 May 2008 10:31:05 pm

You must replace the attribute_view_gui line by something like :

{$node.object.data_map.right_column.content|wash()|extract_left(50)}

Where 50 is the number of chars you would like to keep.

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Brian Henkel

Tuesday 13 May 2008 10:08:58 am

Hmmm, doesn't work for me. Replacing with the following just removed all content from that column:

<div class="right-column-position">
            <div class="right-column">
            <!-- Content: START -->
                    {$node.object.data_map.right_column.content|wash()|extract_left(50)}
            <!-- Content: END -->
            </div>
        </div>

I don't consider myself an administrator or coder, so I'm sure I'm just missing something. However, I do appreciate your help, Maxime!

Maxime Thomas

Wednesday 14 May 2008 12:04:20 am

Ah, ok.
It may be hard so.

What datatype (Textline, Text block, Image, XML block,...) is used for the attribute right_column ? If you don't know where to find this information, you can look at Setup > Classes > Content > <Name of the content class> > <Attribute with the identifier right_column>

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Brian Henkel

Wednesday 14 May 2008 7:33:54 am

I appreciate this, Maxime.

It says:
"5. Right column [XML block] (id:239)
Name:Right column
Identifier:right_column
Flags:Is not required
Is searchable
Does not collect information
Translation is enabled
Preferred number of rows: 20"

Here is a snapshot of this in my admin:
http://bhenkel.echoechoplus.com/rightcolumn.jpg

Maxime Thomas

Wednesday 14 May 2008 10:50:15 pm

Now you know that is a XML Block, you can try to show what inside the content attribute object. When you manipulate :

$node.object.data_map.right_column

It refers to an attribute (regarding to the input form, it'sonly the part concerning the right column). Then, you can show what is inside this object using the attribute(show) function.

{$node.object.data_map.right_column.content|attribute(show)}

It will show a table with 3 columns : attribute, type, value. If nothing appears, there's two reasons : maybe what you have passed as value is not a table or maybe it's null.
For each attribute, you can acces its content by just adding ".content". As above.
If my memory is ok, you would have to add ".output" finally to get get only the XML. Then you must process it to extract only what you want (and escape the XML stuff).

{$node.object.data_map.right_column.content.output}
{$node.object.data_map.right_column.content.output|attribute(show)}

Good luck !

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Peter Putzer

Thursday 15 May 2008 2:31:30 am

Sorry if I wasn't too clear: Of course creating a custom view is needed for the blog snippets. However, the teaser operator lets you get a snippet out of an XMLText attribute.

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 01:24:05
Script start
Timing: Jan 31 2025 01:24:05
Module start 'layout'
Timing: Jan 31 2025 01:24:05
Module start 'content'
Timing: Jan 31 2025 01:24:06
Module end 'content'
Timing: Jan 31 2025 01:24:06
Script end

Main resources:

Total runtime1.2336 sec
Peak memory usage8,192.0000 KB
Database Queries83

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.1328151.2109
Module start 'layout' 0.00560.0038 739.3438220.6875
Module start 'content' 0.00931.2235 960.03134,591.5703
Module end 'content' 1.23290.0007 5,551.601623.8516
Script end 1.2336  5,575.4531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.2929160.0002
Check MTime0.00130.1028160.0001
Mysql Total
Database connection0.00090.071110.0009
Mysqli_queries1.113390.2473830.0134
Looping result0.00090.0707810.0000
Template Total1.180395.720.5902
Template load0.00190.155820.0010
Template processing1.178495.524020.5892
Template load and register function0.00160.126010.0016
states
state_id_array0.00180.149610.0018
state_identifier_array0.00100.081120.0005
Override
Cache load0.00180.1475650.0000
Sytem overhead
Fetch class attribute can translate value0.00230.183130.0008
Fetch class attribute name0.00270.2172130.0002
XML
Image XML parsing0.00380.306630.0013
class_abstraction
Instantiating content class attribute0.00000.0036180.0000
General
dbfile0.00440.3585220.0002
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
11content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
20content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
6content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 51
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs