How to create a link from one article to another in ez publish 3

Author Message

Geir Pedersen

Monday 29 September 2003 3:15:13 am

Can anyone enlighten me as to how I can link from one article to another using ezpublish 3?

Inserting <link id='xxx'> seems to work in a very limited way. I am able to create links to some articles this way, but not to the majority. Also, it seems that sometimes ezpublish will have rewritten a link-element to an a-element when I open an article for further editing.

Is link the right element to use? What attributes are available and how do I specify the article or object I want to link to? Should I modify any configuration files to make this work?

I was sort of expecting that I could use the related object feature to find articles or objects I want to link to and then insert links into the article using a shorthand notation.

Vivienne van Velzen

Monday 29 September 2003 11:18:16 pm

Hi Geir,

You can use object relations to link from one article to another. After you created the object relation, you have to paste the example code into the article you want to link from. The example code is something like: <object id='1594' /> (this is shown under the related object in the editscreen).
Inserting this code will cause a link to appear in the article.
Example:
1. I want to link from article 1 to article 2 (title "I'm linked" ).
2. I create a object relation to article 2 (<object id='1' /> ) in the edit screen of article 1.
3. I then add the following description to article 1:
I'm linking to article 2 from here: <object id='1' />.
4. After publishing article 1, the visitor will see the following text under article 1:
I'm linking to article 2 from here: I'm linked.
(where the link is under "I'm linked" ).

Hope this helps,

Vivienne

Geir Pedersen

Wednesday 01 October 2003 1:02:01 pm

Vivienne,

Thanks for explaining the object-element. Based on your post I understand this is the main method for including links to other on-site articles and objects.

However, when I use this method on the intranet sample site, links are not shown inline in the current paragraph, but shown as block elements. Also, I can't find a way to set the source anchor text, i.e. the text you click on. (I understand this is taken from the object you link to.)

What I am looking for is a way to generate a hypertext link from one article to another article. The link should be displayed as an inline element, and I should be able to control both the anchor text as well as the title-attribute of the anchor element.

Since writing my initial message, I've done a dive into the ez publish 3.2 code to find a way to achieve my goal. I learnt several things:

It is possible to have an object xml element displayed inline in the current paragraph. The file ./design/standard/templates/content/datatype/view/ezxmltags/object.tpl contains a hint on how to do this in the following comment from the file:

Set variable to true if the object should be rendered
as a block tag. If it should be rendered as inline use
false.
{set-block scope=root variable=is_block}true{/set-block}

I tried this, but it did not work.

I went further into the code and discovered that if I made a small change in kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php the is_block variable from above took effect.

What I did was to change this line:

if ( $tpl->hasVariable( 'is_block', 'xmltagns:ContentView' ) )

into this:

if ( $tpl->hasVariable( 'is_block', 'xmltagns' ) )

The change has to do with what namespace hasVariable() checks for presence of is_block. I'm unable to tell if this is a simple typo, or what the full story is here.

After making the change above, I am now able to control via templates if object-elements are displayed inline in the current paragraph or as a separate block-level element.

The next thing I would like to see is a way to control both the anchor text and the title attribute of the html a-element. As far as I can see the ez publish xml object element does not support a title-attribute, but I could be wrong on that. What I would like to see is that the object-element supports two attributes, title and text. The text-attribute can be used to hold what will become the anchor text of the html a-element.

I would love to hear comments from people who really know the ezxmltext code and what the plans are for further development of this module.

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 18 2025 19:34:26
Script start
Timing: Jan 18 2025 19:34:26
Module start 'layout'
Timing: Jan 18 2025 19:34:26
Module start 'content'
Timing: Jan 18 2025 19:34:27
Module end 'content'
Timing: Jan 18 2025 19:34:27
Script end

Main resources:

Total runtime0.9754 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 588.2031152.6563
Module start 'layout' 0.00590.0026 740.859439.4922
Module start 'content' 0.00850.9653 780.3516481.0391
Module end 'content' 0.97380.0015 1,261.390612.0938
Script end 0.9753  1,273.4844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.3743160.0002
Check MTime0.00140.1390160.0001
Mysql Total
Database connection0.00060.064910.0006
Mysqli_queries0.919094.2187570.0161
Looping result0.00050.0537550.0000
Template Total0.947297.120.4736
Template load0.00210.219120.0011
Template processing0.945196.895120.4725
Template load and register function0.00010.014410.0001
states
state_id_array0.00070.072210.0007
state_identifier_array0.00120.124520.0006
Override
Cache load0.00180.1883420.0000
Sytem overhead
Fetch class attribute can translate value0.00050.054020.0003
Fetch class attribute name0.00100.100230.0003
XML
Image XML parsing0.00020.019920.0001
class_abstraction
Instantiating content class attribute0.00000.000830.0000
General
dbfile0.00070.0713100.0001
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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs