Show votes in article header along with author, date etc
Moderators: ooffick, General Support Moderators
Forum rules
-
- Joomla! Apprentice
- Posts: 16
- Joined: Mon Jan 23, 2017 8:36 am
Show votes in article header along with author, date etc
I know if I override content\info_block\block.php I can control a bunch of fields, and to make them appear I do something along the lines of echo JLayoutHelper::render('joomla.content.info_block.author', $displayData);
What I'm trying to do is get the article votes to appear here. it's actually a 3rd party one I'm using which just shows stars, but it's a direct replacement for the default one. I understand they are both implemented as plugins and am guessing that's why I'm having a hard time finding the actual line to invoke them. So if anyone knows what I'd need to add into this block.php to make them appear I'd really appreciate it, thanks.
What I'm trying to do is get the article votes to appear here. it's actually a 3rd party one I'm using which just shows stars, but it's a direct replacement for the default one. I understand they are both implemented as plugins and am guessing that's why I'm having a hard time finding the actual line to invoke them. So if anyone knows what I'd need to add into this block.php to make them appear I'd really appreciate it, thanks.
- effrit
- Joomla! Guru
- Posts: 846
- Joined: Sun Nov 12, 2017 2:21 pm
- Location: middle of Russia
- Contact:
Re: Show votes in article header along with author, date etc
standard vote plugin add its content before or after main content via onContentBeforeDisplay, onContentAfterDisplay events.
this string do the trick.
so to customize, you must store somehow ob_get_clean() data or make regular replacement it your template
for example
replace original string i mentioned to
then in article template you can do
Code: Select all
\plugins\content\vote\vote.php
Code: Select all
$html .= ob_get_clean();
for example
replace original string i mentioned to
Code: Select all
$params->votte = ob_get_clean();
Code: Select all
echo $params->votte;
-
- Joomla! Apprentice
- Posts: 16
- Joined: Mon Jan 23, 2017 8:36 am
Re: Show votes in article header along with author, date etc
I tried using ob_get_clean(); in block.php but it totally screwed the whole site up! I must admit I don't really understand how this is supposed to fit in.
- effrit
- Joomla! Guru
- Posts: 846
- Joined: Sun Nov 12, 2017 2:21 pm
- Location: middle of Russia
- Contact:
Re: Show votes in article header along with author, date etc
logic is simple:
in
\plugins\content\vote\vote.php
you store code in $params->votte
read how ob_get_clean() works in php
and in article template you just draw it by
echo $params->votte;
in
\plugins\content\vote\vote.php
you store code in $params->votte
read how ob_get_clean() works in php
and in article template you just draw it by
echo $params->votte;
http://effrit.com/joomla | clean Word/Excel tables: http://r91228pz.bget.ru
-
- Joomla! Apprentice
- Posts: 16
- Joined: Mon Jan 23, 2017 8:36 am
Re: Show votes in article header along with author, date etc
OK thank you I have made some progress. I have seen the line which constructs the html in the source:
$html .= $this->plgContentExtraVoteStars( $this->article_id, $rating_sum, $rating_count, $article->xid, $ip );
So how do I add this instead to $params? I mean, where you just said "you store code in $params->votte" I can't get the syntax right to do that - what is the line please?
Btw I am working with the 3rd party ExtraVote now directly.
$html .= $this->plgContentExtraVoteStars( $this->article_id, $rating_sum, $rating_count, $article->xid, $ip );
So how do I add this instead to $params? I mean, where you just said "you store code in $params->votte" I can't get the syntax right to do that - what is the line please?
Btw I am working with the 3rd party ExtraVote now directly.
- effrit
- Joomla! Guru
- Posts: 846
- Joined: Sun Nov 12, 2017 2:21 pm
- Location: middle of Russia
- Contact:
Re: Show votes in article header along with author, date etc
Code: Select all
$params->votte = $this->plgContentExtraVoteStars( $this->article_id, $rating_sum, $rating_count, $article->xid, $ip );
http://effrit.com/joomla | clean Word/Excel tables: http://r91228pz.bget.ru
-
- Joomla! Apprentice
- Posts: 16
- Joined: Mon Jan 23, 2017 8:36 am
Re: Show votes in article header along with author, date etc
Hey thanks - I am so close now!
Remember I am working in bock.php.
In that file, if I do
echo $params->votte;
I get crash with undefined variable prams
But I see elsewhere in that file many refs to for example
$displayData['params']->get('show_parent_category')
So I then try
echo $displayData['params']->get('votte')
But it comes out blank however, if I do
var_dump($displayData['params']);
I see the stars - here's the end of the dump, you'll see "1 1 1 1" where I see star icons
["robots"]=> NULL ["access-view"]=> bool(true) } ["initialized":protected]=> bool(true) ["separator"]=> string(1) "." ["votte"]=> string(2106) "
51 1 1 1 1 1 1 1 1 1
" }
It looks like it has passed the html over but I just now need to know how to get it & I'm done!
Remember I am working in bock.php.
In that file, if I do
echo $params->votte;
I get crash with undefined variable prams
But I see elsewhere in that file many refs to for example
$displayData['params']->get('show_parent_category')
So I then try
echo $displayData['params']->get('votte')
But it comes out blank however, if I do
var_dump($displayData['params']);
I see the stars - here's the end of the dump, you'll see "1 1 1 1" where I see star icons
["robots"]=> NULL ["access-view"]=> bool(true) } ["initialized":protected]=> bool(true) ["separator"]=> string(1) "." ["votte"]=> string(2106) "
51 1 1 1 1 1 1 1 1 1
" }
It looks like it has passed the html over but I just now need to know how to get it & I'm done!
- effrit
- Joomla! Guru
- Posts: 846
- Joined: Sun Nov 12, 2017 2:21 pm
- Location: middle of Russia
- Contact:
Re: Show votes in article header along with author, date etc
i an not programmer so its hard for me too )
maybe
maybe
Code: Select all
$displayData['params']->votte;
http://effrit.com/joomla | clean Word/Excel tables: http://r91228pz.bget.ru
-
- Joomla! Apprentice
- Posts: 16
- Joined: Mon Jan 23, 2017 8:36 am
Re: Show votes in article header along with author, date etc
Yay! It works. Thank you x 1 million. I learned a lot there. !!!