Keyword

How to chage the exta field value url link to mail function for k2 item extra feield?

  • pamidipadudravid
  • pamidipadudravid's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 10 months ago #98241 by pamidipadudravid
hai.. i add the extra feild value  for  link  in k2 item extra feild group , example: in froend end ,it like

 

mail: This email address is being protected from spambots. You need JavaScript enabled to view it.

 when we  click it go for some other info.com , like that

 

 

but i need mail to means link MS Office mail for?

i like output like this :    www.w3schools.com/html/tryit.asp?filename=tryhtml_mailto

 

what i do?

 

 

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

More
13 years 10 months ago #98242 by BBC
Try:

jproven.com/extensions/k2fields

 

It has option "pre-configured validated input fields for alpha, alphanum, number, real, integer, email, url".

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

  • pamidipadudravid
  • pamidipadudravid's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 10 months ago #98243 by pamidipadudravid
Thanks for ur  reply.....

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

More
13 years 10 months ago #98244 by matthew turner
Hi,

if you use the switch case break loop in your template over rides (as posted by Daniel Arnolf here - community.getk2.org/forum/topics/output-extra-fields ) you can assign a PHP variable for each of your extrafields individually by ID, you can use a simple textbox extrafield and a bit of html/PHP  to add anything you want !!

<?php foreach ($this->item->extra_fields as $key=>$extraField):    switch($extraField->id) {        case 1:        $EmailAddress = $extraField->value;        break;        case 2:        $EmailSubject = $extraField->value;        break;                case 3:        $EmailLinkText = $extraField->value;        break;                      }endforeach;?>

All you would need to do after adding the code above (as referenced above), would be to echo the textbox variable inside the html email link :

&lt;a href="mailto:&lt;php echo $EmailAddress; ?>?Subject=Hello%20again">Send Mail</a>

or

&lt;a href="mailto:&lt;php echo $EmailAddress; ?>?Subject=<php echo $EmailSubject; ?>">Send Mail</a>

or even

&lt;a href="mailto:&lt;php echo $EmailAddress; ?>?Subject=<php echo $EmailSubject; ?>"><php echo $EmailLinkText; ?></a>
 

I use this method in my templates.... hope this helps you.

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

  • pamidipadudravid
  • pamidipadudravid's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 10 months ago #98245 by pamidipadudravid
www.andhrawishesh.com/k2/item/76-lakshmi-temple-uk.html?ctyi...

 

In above link i  did what i want Mr.mat.., if i click on email  extra field value, it will  fire the  mail to form...

 

Thanka  a lot..... well done

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

More
13 years 10 months ago #98246 by BBC
Does Joomla after this hide email address form spam spiders ?

Need to test.

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

  • pamidipadudravid
  • pamidipadudravid's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 10 months ago #98247 by pamidipadudravid
i cant get your words clearly.. can u tell me clearly?

plzzzzzzz

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

More
13 years 10 months ago #98248 by BBC
Email address is visible for spammers. Sometimes when Joomla detects "&lt;a href="mailto:" it hides email in js code snippet to hide it.

 

But i cannot ge it to work. Don´t know what wrong i am doing. So Mat, if you can please explain it step by step ?

I don´t want to echo extra field to some special place in Item, but to use extra field already among other extra fields. Just to be clickable.

 

Can´t get it to work both way. Checked other topic too.

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

More
13 years 10 months ago #98249 by BBC
I changed this:

case 1: $EmailAddress = $extraField-&gt;value; 

 

to:

case 11:$Email = $extraField-&gt;value; 


&lt;a href="mailto:&lt;php echo $Email; ?>?Subject=Hello%20again">Send Mail</a> 

 

This is my field ID and field name, but no difference.

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

More
13 years 10 months ago #98250 by matthew turner
Hi

My bad, I just noticed a typo with the code I posted above...sorry

should have been:

&lt;a href="mailto:&lt;?php echo $EmailAddress; ?>?Subject=Hello%20again">Send Mail</a>

 

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

More
13 years 10 months ago #98251 by BBC
I get nothing at the frontend. I must be dumb.

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

More
13 years 10 months ago #98252 by BBC
It works now. If you call it only in Item text area.

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

More
13 years 10 months ago #98253 by matthew turner
Hi BBC,

The code would need adding per template (category_item.php, latest_item.php etc) and can be used in the K2 content module template over rides as well....

On the Joomla protecting the email address from spammers, I'm looking into that, I think it may be Joomla only protecting the email address inside of main content area(or intro text)....

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

More
13 years 10 months ago #98254 by BBC
I am testing it in item.php.

 

I need some option to turn ordinary Text Field into clickable email address, if it detects "@" in field.

Some simple solution. There are 5-6 files in admin/components/com_k2 that needs to be changed. But it is to much core changing for such small benefit.

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

More
13 years 10 months ago #98255 by BBC
You can try tweak code from user.php:

&lt;?php echo JHTML::_('Email.cloak', $this-&gt;user-&gt;email); ?&gt; 

 

Email.cloak hides email addresses.

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

More
13 years 10 months ago #98256 by matthew turner
Hi BBC,

The above works nicely !

Just out of curiosity I tested the Extrafields plugin code that I posted for Jock (for the Gallery plugin) and that did the same wrap in javascript routine:

 

&lt;?php echo JHTML::_('content.prepare', $EmailAddress ); ?&gt;

 

Which again wraps it in Javascript - Joomla built in ?

Not sure at this moment how to add in/change the subject line...

Working on that next

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

More
13 years 10 months ago #98257 by BBC
This with extra fields will kill K2. People run away to SobiPro, Flexicontent and Jsblod.

 

Didn´t tried in deep last two, but Sobi is not near K2. And it would be shame to lose users just because of extra fields.

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

More
13 years 10 months ago #98258 by BBC
I woudn´t mind to pay yearly subscription just to have some pro documentation.

Some code snippets you can use in templates, some core (code) tweaks, etc...

 

I am aware that developers are not so eager to put new options, etc... K2 could slow down. But some central place where you can read documentation would be OK.

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

More
13 years 10 months ago #98259 by BBC
How your code for mail looks now ?

I don´t need it now, but paste it here for some future use.

 

All i got with my code was javascript code in address field, in mail client.

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

More
13 years 10 months ago #98260 by matthew turner
Hi BBC,

Got it sorted in the last couple of minutes....Using the code you posted, with a bit of string replacement...  ;)

 

&lt;?php

$myhiddenemail = JHTML::_('Email.cloak', $EmailAddress); $JscriptSubject = "var suffix = ''";$EmailSubject   = "var suffix = '?Subject=Hello%20again'";$myNEWhiddenemail = str_replace($JscriptSubject, $EmailSubject, $myhiddenemail);

?&gt;

&lt;?php echo JHTML::_('content.prepare', $myNEWhiddenemail ); ?&gt;

 

This could be further modified if you echo another extrafield variable in place of the Hello%20again bit

I think this is part of how Joomla is coded, plugins, replacements etc to just work in the main content area...

K2 presents ways around nearly all of my issues of the standard Joomla.

Not sure how I got anything done before I started using K2 as I have found this forum and community to be a fantastic resource of information (including some from your posts BBC !) and similar minded people - I have learned so much about PHP,JSON,MySql etc from this forum and related searches to achieve my clients needs....

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


Powered by Kunena Forum