Forums / Setup & design / Blog snippet on homepage

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

eZ debug

Timing: Jan 30 2025 21:37:27
Script start
Timing: Jan 30 2025 21:37:27
Module start 'content'
Timing: Jan 30 2025 21:37:27
Module end 'content'
Timing: Jan 30 2025 21:37:27
Script end

Main resources:

Total runtime0.3106 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 589.0625370.2969
Module start 'content' 0.00630.0102 959.35941,017.6406
Module end 'content' 0.01660.2940 1,977.00003,905.5625
Script end 0.3106  5,882.5625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00471.5038200.0002
Check MTime0.00140.4517200.0001
Mysql Total
Database connection0.00080.244610.0008
Mysqli_queries0.213068.55681410.0015
Looping result0.00170.53491390.0000
Template Total0.293594.510.2935
Template load0.00090.281410.0009
Template processing0.292694.204010.2926
Override
Cache load0.00060.190010.0006
Sytem overhead
Fetch class attribute can translate value0.00180.582410.0018
XML
Image XML parsing0.00030.092710.0003
General
dbfile0.00531.7052200.0003
String conversion0.00000.001530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs