Forums / Setup & design / How to create a link from one article to another in ez publish 3

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.

eZ debug

Timing: Jan 19 2025 00:31:51
Script start
Timing: Jan 19 2025 00:31:51
Module start 'content'
Timing: Jan 19 2025 00:31:53
Module end 'content'
Timing: Jan 19 2025 00:31:53
Script end

Main resources:

Total runtime1.9830 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0097 587.9844180.7969
Module start 'content' 0.00971.8142 768.7813486.1484
Module end 'content' 1.82390.1591 1,254.9297337.4688
Script end 1.9830  1,592.3984 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00450.2278210.0002
Check MTime0.00190.0956210.0001
Mysql Total
Database connection0.00070.036410.0007
Mysqli_queries1.912396.43321940.0099
Looping result0.00230.11671920.0000
Template Total1.943998.020.9720
Template load0.00230.117520.0012
Template processing1.941697.910420.9708
Template load and register function0.00030.014710.0003
states
state_id_array0.00200.101710.0020
state_identifier_array0.00090.045620.0005
Override
Cache load0.00190.0980420.0000
Sytem overhead
Fetch class attribute can translate value0.00150.075030.0005
Fetch class attribute name0.00140.069130.0005
XML
Image XML parsing0.00070.034230.0002
class_abstraction
Instantiating content class attribute0.00000.000430.0000
General
dbfile0.00210.1055210.0001
String conversion0.00000.000530.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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