solved Latest profile youtube added used in a profile

MAD
MAD
@madc
10 years ago
600 posts
I have added an affiliate profile page and want to add the latest youtube video they have added to our site in their own header template on their created profile page.
How would I do that?

I have tried this
Added in their profile header template
( profile_htp_header.tpl )

{jrCore_list module="jrYoutube" template="htpyoutube.tpl" limit=1}

and the htpyoutube.tpl is this

{if isset($_items)}
<div style="display: inline-block; width:100%">
    {jrYouTube_embed profile_id=$_profile_id item_id=$item._item_id type="iframe" width="100%"}
</div>
{/if}

Haven't tried adding any youtube videos outside of the normal areas yet only audio
So this has me stumped

Link where their videos are
https://www.punkbandpromotions.com/hear-this-promotions/youtube
I just want to add an autoplay their latest added one beside their header logo to the right.


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion

updated by @madc: 05/20/14 05:30:18PM
paul
@paul
10 years ago
4,326 posts
You've missed the {foreach from=$_items item="item"} loop out of the template -
{if isset($_items)}
{foreach from=$_items item="item"}
<div style="display: inline-block; width:100%">
    {jrYouTube_embed profile_id=$_profile_id item_id=$item._item_id type="iframe" width="100%" auto_play=true}
</div>
{/foreach}
{/if}

Alternatively, just put the embed call straight in the header template -

{jrYouTube_embed profile_id=$_profile_id item_id=x type="iframe" width="100%" auto_play=true}

where 'x' is the item_id of the youtube.
Pa


--
Paul Asher - JR Developer and System Import Specialist
MAD
MAD
@madc
10 years ago
600 posts
Yeah great @paul. But I want to put in their latest added youtube video not the ID. Any way to do that ?
So when the Affiliate uploads a new youtube video it will change from the old one to the latest


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion
brian
@brian
10 years ago
10,148 posts
Just add:

order_by="_created numerical_desc" limit="1"

instead of specifying the item_id in the jrCore_list call.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
MAD
MAD
@madc
10 years ago
600 posts
Nope still not working
I tried with @pauls edit and yours brian as I know what your is doing
But it is still showing up blank with no errors. Any other thoughts?


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion
brian
@brian
10 years ago
10,148 posts
MAD©:
Nope still not working
I tried with @pauls edit and yours brian as I know what your is doing
But it is still showing up blank with no errors. Any other thoughts?

I'm guessing that means it is not find anything. This call:

{jrCore_list module="jrYouTube" order_by="_created numerical_desc" limit=1}

Should show you the very latest youtube video in your system - if it does not, then either there are no YouTube videos loaded or something is wrong.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
MAD
MAD
@madc
10 years ago
600 posts
If I use just
{jrYouTube_embed profile_id=$_profile_id order_by="created numerical_desc" limit="1" type="iframe" width="100%" auto_play=true}

in their template it shows

jrYouTube_embed: invalid item_id


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion
MAD
MAD
@madc
10 years ago
600 posts
BTW your post above mine shows the video ( last added ) as a list but I want the player and I want it to autoplay that profiles last added youtube not the list . I want a youtube video box that autplays?
In other words look at this page
https://www.punkbandpromotions.com/loud-fast-shitty/podcasts
Same position, I have a livestream pulled in which is external
I want to pull in an internal youtube video that they have just added.
No matter if they pull in 5 the last one needs to be showing ( they will know )


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion

updated by @madc: 04/05/14 07:50:44AM
paul
@paul
10 years ago
4,326 posts
jrYouTube_embed does need the youtube id to work. Your code isn't providing it.


--
Paul Asher - JR Developer and System Import Specialist
MAD
MAD
@madc
10 years ago
600 posts
Ok, Anyway to just get the last youtube video they added into a section of the header without them having to work out what ID etc?

EDIT
If I throw in an ID it works
But I don't want that as the affiliate is never going to know the id
I want THEIR last added youtube vid goes in there?


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion

updated by @madc: 04/05/14 07:57:36AM
brian
@brian
10 years ago
10,148 posts
MAD©:
Ok, Anyway to just get the last youtube video they added into a section of the header without them having to work out what ID etc?

Yeah - you need to:

- use a jrCore_list call to get the ID
- save the ID using the "assign" param
- use the assigned variable as the input to the jrYouTube_embed call:

{capture name="template" assign="tpl"}
{literal}
{$_items[0]._item_id}
{/literal}
{/capture}
{jrCore_list module="jrYouTube" profile_id=$_profile_id order_by="_created numerical_desc" limit=1 template=$tpl assign="youtube_id"}
{jrYouTube_embed profile_id=$_profile_id item_id=$youtube_id type="iframe" width="100%" auto_play=true}

So you can see how we:

1) Create an inline template using capture and literal
2) run a jrCore_List call to get just a single item_id
3) pass that item_id into the jrYouTube_embed call

I just typed that out here without testing, so you may need to tweak it, but that should give you the idea.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 04/05/14 08:00:19AM
paul
@paul
10 years ago
4,326 posts
    {capture name="template" assign="youtube_tpl"}
        {literal}
            {foreach $_items as $title => $item}
                {jrYouTube_embed type="iframe" width="100%" item=$item auto_play=true}
            {/foreach}
        {/literal}
    {/capture}
    {jrCore_list module="jrYouTube" order_by="_created numerical_desc" limit=1 search="_profile_id = `$_profile_id`" template=$youtube_tpl}



--
Paul Asher - JR Developer and System Import Specialist
brian
@brian
10 years ago
10,148 posts
Looks like you got 2 ways ;)

I'll let Paul help you out!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
MAD
MAD
@madc
10 years ago
600 posts
Nope still no go :(
Tried both with tweaks
same thing
Can't find the ID


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion
MAD
MAD
@madc
10 years ago
600 posts
Ok i got @pauls code to work with changing the tpl name from youtube_tpl to youtube.tpl
But it still only shows a list and not a player?

This is the code straight in the profile template

{capture name="template" assign="htp_youtube.tpl"}
        {literal}
            {foreach $_items as $title => $item}
                {jrYouTube_embed type="iframe" width="100%" item=$item auto_play=true}
            {/foreach}
        {/literal}
    {/capture}
    {jrCore_list module="jrYouTube" order_by="_created numerical_desc" limit=1 search="_profile_id = `$_profile_id`" template=$htp_youtube.tpl}

Page is https://www.punkbandpromotions.com/hear-this-promotions/youtube
I will leave it up as its am here in oz :p


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion

updated by @madc: 04/05/14 08:55:00AM
paul
@paul
10 years ago
4,326 posts
The URL you give is the URL to list ALL of a profile's youtubes. I thought this was sometime in the header?
I don't think my code is being run, or its erroring. assigning to 'htp_youtube.tpl' will not work as smarty will think that is an array. There's no reason why my assign to 'youtube_tpl' will not work, I do things like that all the time.


--
Paul Asher - JR Developer and System Import Specialist
MAD
MAD
@madc
10 years ago
600 posts
Thanks @paul.
I reverted to your code above and it still didn't work.

Then I changed this

{jrYouTube_embed type="iframe" width="100%" item=$item auto_play=true}

to this

{jrYouTube_embed type="iframe" item_id=$item._item_id auto_play=true width="100%"}

And it worked
Thanks for everything guys!


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion
MAD
MAD
@madc
10 years ago
600 posts
One last question, Does the jrYoutube module have any code to

hide suggested videos when the video finishes https://developers.google.com/youtube/player_parameters#rel

and

also to loop? https://developers.google.com/youtube/player_parameters#loop


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion
paul
@paul
10 years ago
4,326 posts
MAD©:
One last question, Does the jrYoutube module have any code to

hide suggested videos when the video finishes https://developers.google.com/youtube/player_parameters#rel

and

also to loop? https://developers.google.com/youtube/player_parameters#loop

Tricky one that. In short, no. Something would have to detect when the video had finished, but how would it know? If the streaming stopped, it might be just because it stuttered because of a slow connection.
I did once, for a client, do a YT playlist and start a timer based on the YT length in its data, then move on to the next one when timeout occurred. Again, not ideal as the timer may not be totally accurate, or the video may have took a bit of time to start, to have stuttered, so it'll get truncated.

Unless there's are easier trick to this that I'm missing?


--
Paul Asher - JR Developer and System Import Specialist

Tags