Forums / Developer / Passing href attribute value [SOLVED]

Passing href attribute value [SOLVED]

Author Message

Lo' F.

Tuesday 19 October 2010 4:13:09 am

Hi again!

I am puzzling over one thing and I was wondering if there may be one ready to go solution which I might not be aware of!

I have a frontpage object devided into two columns.

In the right column I have a list of videos and it will be nice and cool to see the clicked video in the left column of this page.

I have racked my brain over it, since I have trouble passing the clicked video's file path to the href attribute of an <a> tag of an external template containing the script used to render these videos which I included in this page's left column.

I really, really, really look forward to your help!!

Thanks a lot!

loredanaebook.it

Lo' F.

Tuesday 19 October 2010 9:28:08 am

I have been trying implementing an ajax script but just can pass the template content into a div, not able to pass value to its <a href=..>.

So I skipped Ajax for jQuery but when I pass the value through jquery.. cannot make it work - when I click the video it just ignores the given video's path (the player behaves as it is searching for the file and cannot find it) even though on mouse over this path is displayed in the browser status bar and in firebug the value matches the href attribute.

This is the jquery script inserted in the head of pagelayout.tpl:

{literal}
<script type="text/javascript">
var videoPath = "";
var videoTitle = "";
$(document).ready(function() {
  $("a#video").click(function() { 
    videoPath = $(this).attr('href');
    videoTitle = $(this).attr('title');
    //alert(videoPath + "\r\n " +videoTitle);
    return false;
  });
});

$(document).ready(function() {
  $("a#player").attr({href: videoPath, title: videoTitle});
});
</script>
{/literal}

..

If there might be something to accomplish what I am trying to do, which has more to do with ez publish I am all ears!

Or if you can see any flaw in here why it is behaving such so, any hint would be, as always, highly appreciated!

loredanaebook.it

Lo' F.

Wednesday 20 October 2010 5:37:08 am

..made a teeny-tiny progress but still couldn't get it work properly.

I added this line too..

$('object#videoplayer_api param[name=flashvars]').attr('value','config={"clip":{"autoPlay":false,"autoBuffering":true,"url":"' + videoPath + '"},"playerId":"player","playlist":[{"autoPlay":false,"autoBuffering":true,"url":"' + videoPath + '"}]}');

..to pass the variable value to the rendered object (which comes compiled when the page is loaded - the original script recalls just an <a> tag and a floplayer's script).

The progress is that, with this line, unlike before, when the page is loaded the player get the default videoPath value and plays that video.

But if I click on other videos' link, it successflully passes the related value to the code (which I can see from firebug) but it still keeps playing the default video.

One strange thing I noticed is that in IE, when checking the code through its developers tool, the above code has no value within the brackets of clip: and playlist:.

loredanaebook.it

Quoc Huy Nguyen Dinh

Wednesday 20 October 2010 6:04:03 am

Is it what you want to get?

<html>

<head>
<style>
#player {
width: 480px;
height: 385px;
border: solid 1px #000;
float: left;
margin-right: 15px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
  $(".video").click(function() {
    $("#player").html('<object width="480" height="385"><param name="movie" value="' + $(this).attr('href') + '"></param><param value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+ $(this).attr('href') +'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>');
    return false;
  });
});
</script>
</head> 

<body>
<div id="player"></div>
<div id="list">
Video list:<br/>
<a href="http://www.youtube.com/v/Ylco0bkFYIo?fs=1&amp;hl=en_US" class="video">eZ Publish 4.3 demo</a><br/>
<a href="http://www.youtube.com/v/w4Rx1U-heYg?fs=1&amp;hl=en_GB" class="video">eZ Awards 2010</a>
</div>
</body></html>

Quoc Huy Nguyen Dinh

Wednesday 20 October 2010 6:19:34 am

When you use the <embed> tag, the URL of that tag is the SWF player which in turns load the URL of the video.

I might be wrong but I don't think you can dynamically change the URL video as it is internal to the SWF unless you recode the SWF to support this.

You need to rebuild the whole <embed> HTML code and replace the existing one as my example above.

Lo' F.

Friday 22 October 2010 12:43:07 pm

Hi Quoc Huy, thanks for your reply!

More or less it was that what I was aiming to do, but had to pass the video path to a Flowplayer object (which is created by a flowplayer script )

I finally managed to dynamically change the URL video this way:

- just set this script in the head of the document..

{literal}
  <script type="text/javascript">
    $(document).ready(function() {
      $("a.video").click(function () {
         mediaplayer.setClip({url: $(this).attr("href")});
         return false;
      });
    });
  </script>
{/literal}

- embedded this script in an external template included into a div of my frontpage left column..

<a style="display:block;width:500px;height:300px;"  id="player"></a>
<script type="text/javascript" language="javascript">
    mediaplayer = flowplayer("player", "/extension/ezextension/design/ezextension/javascript/flowplayer/flowplayer-3.2.5.swf", {
                  clip: {
                       autoPlay: false,
                       autoBuffering: true
                  }
    });
</script>

- and set a class name for the <a> tag of each fetched video where the event comes triggered..

{def $videos=fetch('content', 'tree', hash('parent_node_id', 2, 'class_filter_type', 'include', 'class_filter_array', array('video_content')))}
{foreach $videos as $video}
    <a href="{concat('/', $video.data_map.video.content.filepath)}" title="{$video.data_map.title.content}" class="video">Watch video</a>
{/foreach}

loredanaebook.it

Quoc Huy Nguyen Dinh

Monday 25 October 2010 7:44:21 am

So Flowplayer has been built with this in mind.

Great stuff!

eZ debug

Timing: Jan 18 2025 02:14:45
Script start
Timing: Jan 18 2025 02:14:45
Module start 'content'
Timing: Jan 18 2025 02:14:46
Module end 'content'
Timing: Jan 18 2025 02:14:46
Script end

Main resources:

Total runtime0.8896 sec
Peak memory usage4,096.0000 KB
Database Queries206

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.8672180.8359
Module start 'content' 0.00540.7597 769.7031616.4141
Module end 'content' 0.76510.1244 1,386.1172345.6797
Script end 0.8895  1,731.7969 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4091210.0002
Check MTime0.00140.1590210.0001
Mysql Total
Database connection0.00060.066810.0006
Mysqli_queries0.803190.28222060.0039
Looping result0.00230.26272040.0000
Template Total0.865297.320.4326
Template load0.00200.224120.0010
Template processing0.863297.037720.4316
Template load and register function0.00010.011310.0001
states
state_id_array0.00100.108810.0010
state_identifier_array0.00090.101620.0005
Override
Cache load0.00180.2008530.0000
Sytem overhead
Fetch class attribute can translate value0.00190.214830.0006
Fetch class attribute name0.00110.123190.0001
XML
Image XML parsing0.00130.144330.0004
class_abstraction
Instantiating content class attribute0.00000.0033140.0000
General
dbfile0.00230.2601350.0001
String conversion0.00000.000830.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
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 33
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs