Keyword

Email button in category item view

  • Adam O.
  • Adam O.'s Avatar Topic Author
  • Offline
  • New Member
More
10 years 8 months ago - 10 years 8 months ago #124215 by Adam O.
Email button in category item view was created by Adam O.
Hi there!

I will add to category_item.php Email button, to send link with item to other friends - the same as in item.php view:

<?php if($params->get('itemEmailButton') && !JRequest::getInt('print')): ?>
<li class="itemEmail">
<a rel="nofollow" href="<?php echo $this->item->emailLink; ?>" onclick="window.open(this.href,'emailWindow','width=400,height=350,location=no,menubar=no,resizable=no,scrollbars=no'); return false;">
<?php echo JText::_('K2_EMAIL'); ?>
</a>
</li>
<?php endif; ?>

when I copy these lines to category_item.php I see an error:

Fatal error: Call to a member function get() on a non-object in
com_k2/templates/default/category_item.php on line 20

how can I rewrite the code to make it working? :-)

I'll be very grateful for your help!

best regards!
Adam

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 8 months ago #124216 by Yiota
Replied by Yiota on topic Re: Email button in category item view
Try to add this code:
<?php require_once (JPATH_SITE.DS.'components'.DS.'com_mailto'.DS.'helpers'.DS.'mailto.php');
    $this->item->emailLink = JRoute::_('index.php?option=com_mailto&tmpl=component&link='.MailToHelper::addLink($this->item->absoluteURL)); ?>      
    <div class="itemEmail"> 
      <a rel="nofollow" href="<?php echo $this->item->emailLink; ?>" onclick="window.open(this.href,'emailWindow','width=400,height=350,location=no,menubar=no,resizable=no,scrollbars=no'); return false;"> 
        <?php echo JText::_('K2_EMAIL'); ?> 
      </a> 
    </div> 

Please Log in or Create an account to join the conversation.

  • Adam O.
  • Adam O.'s Avatar Topic Author
  • Offline
  • New Member
More
10 years 8 months ago #124217 by Adam O.
Replied by Adam O. on topic Re: Email button in category item view
Hello,

many thanks for this code. It opens me correct window, but after fill every field and after click 'Send' button it shows me information:

Attention! Letter is not send!

And nothing more happend...

Do you know why it not sends me this message?

best regards!
Adam

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 8 months ago #124218 by Yiota
Replied by Yiota on topic Re: Email button in category item view
When you choose to email from the item view, and not the category item link, does the email been sent or do you get the same error?

Please Log in or Create an account to join the conversation.

  • Adam O.
  • Adam O.'s Avatar Topic Author
  • Offline
  • New Member
More
10 years 8 months ago #124219 by Adam O.
Replied by Adam O. on topic Re: Email button in category item view
ok I got it :)

by comment out a few lines in controller on com_mailto


many thanks for your help!
Adam

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 8 months ago #124220 by Yiota
Replied by Yiota on topic Re: Email button in category item view
You are welcome. Glad you sorted it out.

Please Log in or Create an account to join the conversation.

  • Adam O.
  • Adam O.'s Avatar Topic Author
  • Offline
  • New Member
More
10 years 7 months ago #124221 by Adam O.
Replied by Adam O. on topic Re: Email button in category item view
Hi again,

previously I don't note, that when I send email via com_mailto, it not sends me link to this article... :-(

please, could you help me?

best wishes!
Adam

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 7 months ago #124222 by Yiota
Replied by Yiota on topic Re: Email button in category item view
Try to add also these two above the require once in the <?php tag.

// Absolute URL
$uri = JURI::getInstance();
$item->absoluteURL = $uri->toString();

Please Log in or Create an account to join the conversation.

  • Adam O.
  • Adam O.'s Avatar Topic Author
  • Offline
  • New Member
More
10 years 7 months ago #124223 by Adam O.
Replied by Adam O. on topic Re: Email button in category item view
no, not working..

in item view of course works everything ok, but in category_item.php view sends still mail without link to an article :(

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 7 months ago #124224 by Yiota
Replied by Yiota on topic Re: Email button in category item view
Try instead of

$item->absoluteURL = $uri->toString();

to put

$this->item->absoluteURL = $uri->toString();

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum