Keyword

k2 extra fields field mailto or remove http://

  • Brigitte Kuschel
  • Brigitte Kuschel's Avatar Topic Author
  • Offline
  • New Member
More
11 years 1 month ago #117519 by Brigitte Kuschel
k2 extra fields field mailto or remove http:// was created by Brigitte Kuschel
hello,
first of all i love k2 and use it in every website.

i have a problem with extra field. I need a field with a email-adress (mailto:).

I tried many thinks.

I think the fastest solution would be to remove the default-link http:// , when i create a new link field, so i can put there everythin i want.

Do you know how i can remove the default-link (which file do i have to change?)

Thank you very much for your answer

Brigitte

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 1 month ago #117520 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: k2 extra fields field mailto or remove http://
Hello Brigitte,

If you want complete control over the output (and possibly use an email cloacker so you don't get tons of spam) I suggest you use two text fields, one for the link and one for the title of the link.

This snippet will help you in directly outputting extrafields getk2.org/community/New-to-K2-Ask-here-first/171284-Where-to-edit-K2-after-Item-Fields

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Brigitte Kuschel
  • Brigitte Kuschel's Avatar Topic Author
  • Offline
  • New Member
More
11 years 1 month ago #117521 by Brigitte Kuschel
Replied by Brigitte Kuschel on topic Re: k2 extra fields field mailto or remove http://
Hello Krikor,

ok,

you say i should put a snippet like this into the file item.php (i find in com_k2/models:

<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<?php if(isset($this->item->extraFields->EMail->value)): ?>
<?php echo $this->item->extraFields->text_email->name; ?>
<?php echo $this->item->extraFields->EMail->value; ?>
<?php endif; ?>
<?php endif; ?>

But i dont know where? i always get an error.

and: is the email field a text-field? How does it know, that i want to make a link with mailto:???

Thank you for your help.

Brigitte

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 1 month ago #117522 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: k2 extra fields field mailto or remove http://
You should read the full (but small) tutorial as described in this blog post.
getk2.org/blog/1068-k2-v262-now-available

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Brigitte Kuschel
  • Brigitte Kuschel's Avatar Topic Author
  • Offline
  • New Member
More
11 years 1 month ago - 11 years 1 month ago #117523 by Brigitte Kuschel
Replied by Brigitte Kuschel on topic Re: k2 extra fields field mailto or remove http://
Hello Krikor,

i read it already very carefully , but i still don't know where to put the changes and it does not say how the program knows that a text-field should be a link or a mailto (this i can try, if i know where to put the code (not which file, but where, there are a lot of statements with extra-fields)

I tried here:
i put this on line 754 on item.php (i find in com_k2/models:

//extra field mit text
if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)):
if(isset($this->item->extraFields->InhaltEmail->value)):
echo $this->item->extraFields->text_email->name;
echo $this->item->extraFields->InhaltEmail->value;
endif;
endif;

before the statements

//K2 plugins
$item->event->K2BeforeDisplay = '';
$item->event->K2AfterDisplay = '';
$item->event->K2AfterDisplayTitle = '';
$item->event->K2BeforeDisplayContent = '';
$item->event->K2AfterDisplayContent = '';

now i get the error on the frontend:

Fatal error: Call to a member function get() on a non-object in /home/www/impuls/components/com_k2/models/item.php on line 756

you see it here
www.webmanagement-allgaeu.de/index.php/mitglieder/mitglieder1

This is what i need:
I only need a field where i can put a email-adress with a link to the standard email-program (mailto). :(

change:
now i see, that the email-Adress in a text-field automatically makes the link with mailto. Without some changes. Can i leave it like this? Or do i get spam then.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 1 month ago #117524 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: k2 extra fields field mailto or remove http://
Brigitte, you need to study a bit about overriding before pasting code. The code should be added in item.php.

I am sorry if I made this a bit difficult I was just pointing to the optimal solution (which requires some coding).

For just a quick and dirty solution you can google for a simple email cloacker.

Should your project require overriding I strongly recommend reading this post before doing anything. 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.


Powered by Kunena Forum