- Posts: 4
COMMUNITY FORUM
Flattr integration with K2
- Dani
- Topic Author
- Offline
- New Member
Less
More
9 years 10 months ago #135551
by Dani
Flattr integration with K2 was created by Dani
Hello, I would love to be able to add a Flattr button for each K2 item (article) so that users can give a tip to the author for the current item. It just needs a custom user field in the user profile for the Flattr username, and some template edits to show the Flattr button for the current item. Any suggestions?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 10 months ago #135583
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Flattr integration with K2
You can override the item.php file and add flattr's code.
This post will help you: getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
This post will help you: getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Dani
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
9 years 10 months ago #135598
by Dani
Replied by Dani on topic Flattr integration with K2
Thanks, but I guess this would only work if there were only one author on the site, or if everyone would share the same Flattr account. What if there are multiple authors, each with their own Flattr username?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 10 months ago #135603
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Flattr integration with K2
Then this has to done via a custom K2 plugin.
If there is nothing similar posted at the JED, it needs to be a custom job.
As a starting point you can use this: getk2.org/extend/extensions/90-example-k2-plugin-for-developers
If there is nothing similar posted at the JED, it needs to be a custom job.
As a starting point you can use this: getk2.org/extend/extensions/90-example-k2-plugin-for-developers
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Dani
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
9 years 10 months ago #135606
by Dani
Replied by Dani on topic Flattr integration with K2
The closest plugin I have found is User Extended Fields for K2, but it only fixed fields, and no field Flattr. If there was a Flattr field, I would be halfway. Then I just would need to find a way to print the flattr username in the template.
Thanks, will check your link.
Thanks, will check your link.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 10 months ago #135609
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Flattr integration with K2
You can extend that plugin (rename it as well) and create new fields so the flattr username can be saved. Then in your overrides from the user's object print that value directly on your template.
The example plugin works in the exact opposite way. You can use this to add data specific to each item.
The example plugin works in the exact opposite way. You can use this to add data specific to each item.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Dani
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
9 years 10 months ago #135618
by Dani
Replied by Dani on topic Flattr integration with K2
Thank. I came to think about that I can't solve it that way because there are about 10 authors and only 3 publishers. So I created an extra field for items instead. The publisher will have to add the author's Flattr uid for each item. Not an ideal solution, but I think I have solved it.
I overrided item.php and placed this code
And I also had to alter the extra fields loop a bit
Tell me if you see any obvious things I could have done in an easier way.
I overrided item.php and placed this code
<?php
$flattr_uid = $this->item->extra_fields[7]->value;
if ($flattr_uid) : ?>
<div class="itemFlattrButton">
<script id='fbf0uil'>(function(i){var f,s=document.getElementById(i);f=document.createElement('iframe');f.src='//api.flattr.com/button/view/?uid=<?php echo $flattr_uid?>&url='+encodeURIComponent(document.URL);f.title='Flattr';f.height=62;f.width=55;f.style.borderWidth=0;s.parentNode.insertBefore(f,s);})('fbf0uil');</script>
</div>
<?php endif; ?>
And I also had to alter the extra fields loop a bit
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->value != '' && $extraField->alias != 'flattr_uid') : ?>
Tell me if you see any obvious things I could have done in an easier way.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 10 months ago #135632
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Flattr integration with K2
Come to think of it, with only 3 publishers, this is the ideal solution. It saved you some hours of development :)
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.