How to implement that block directly into a theme?
Permalink Browser Info Environment
I just purchased that add-on, now i'm wondering how to implement it directly into the footer.php of my theme, just to hide the email adress of my client from spam bots. Is there a way to achieve that?
Michael
Michael
Type: | Discussion |
---|---|
Status: | New |
Hi Steve!
Thank you for your super-speedy repy!
Unfortunately i don't know where exactly to put the code snippets you provided. And where do the additional options go?
This should go to the header.php of my theme (where actually, between the head tags...?)
This should go to the footer.php or anyplace where the email/link should appear, e.g. left_sidebar.php or another page type, right?
Cheers,
Michael
Thank you for your super-speedy repy!
Unfortunately i don't know where exactly to put the code snippets you provided. And where do the additional options go?
This should go to the header.php of my theme (where actually, between the head tags...?)
<?php $eeaJSFile = 'eea.min.js'; $pkgName = 'pmw_encrypted_email_address'; $this->addHeaderItem( $html->javascript( $eeaJSFile, $pkgName )); ?>
This should go to the footer.php or anyplace where the email/link should appear, e.g. left_sidebar.php or another page type, right?
<?php $pkgName = 'pmw_encrypted_email_address'; //Load the EEA library file Loader::library('eea', $pkgName); //Output the encrypted address echo new PmwEncryptedEmailAddress( 'mail@email.com' ); ?>
Cheers,
Michael
> This should go to the header (where, between the head tags...?)
Yep, between the head tags will work fine. You can of course distill it down to...
...I just like using variables for clarity, but string literals work fine.
> This should go to the footer or anyplace where the email/link should appear, right?
Correct, any place you want to display an encrypted address. Of course, you need load the EEA library file only once within any given PHP file, and then you can encrypt/output as many addresses as you'd like.
The EEA constructor method takes an optional second argument which is an array of output options for the encrypted address...
Let me know if there's anything else.
-Steve
Yep, between the head tags will work fine. You can of course distill it down to...
$this->addHeaderItem( $html->javascript( 'eea.min.js', 'pmw_encrypted_email_address'));
...I just like using variables for clarity, but string literals work fine.
> This should go to the footer or anyplace where the email/link should appear, right?
Correct, any place you want to display an encrypted address. Of course, you need load the EEA library file only once within any given PHP file, and then you can encrypt/output as many addresses as you'd like.
// Need to load EEA class only once within a given PHP file Loader::library('eea', 'pmw_encrypted_email_address');
The EEA constructor method takes an optional second argument which is an array of output options for the encrypted address...
$addressToEncrypt = 'email.address@company.com'; $eeaOptions = array( 'isLink'=> 1, // 0 to display address only - i.e. no hyperlink 'subj' => 'Web Inquiry', 'body' => 'Details of inquiry...', 'text' => 'contact us' ); // Encrypt the address with supplied options $encryptedAddress = new PmwEncryptedEmailAddress( $addressToEncrypt, $eeaOptions ); // Output the encrypted address/link echo $encryptedAddress;
Let me know if there's anything else.
-Steve
Thank you so much for your help, and sorry... as i still don't get it to work...
Let me sum up what i have tried:
I installed your add-on.
I put this code into the head section of the header.php of my theme:
Then i put this code into the html of the footer.php of my theme, where the enrypted email should appear:
But i still can't figure out where that code should go:
Sorry for being so stupid... at least this thread maybe help others too.
Michael
Let me sum up what i have tried:
I installed your add-on.
I put this code into the head section of the header.php of my theme:
<?php $this->addHeaderItem( $html->javascript( 'eea.min.js', 'pmw_encrypted_email_address')); ?>
Then i put this code into the html of the footer.php of my theme, where the enrypted email should appear:
<?php $addressToEncrypt = 'email.address@my_clients_company.com'; $eeaOptions = array( 'isLink'=> 1, // 0 to display address only - i.e. no hyperlink 'subj' => 'Web Inquiry', 'body' => 'Details of inquiry...', 'text' => 'Email' ); // Encrypt the address with supplied options $encryptedAddress = new PmwEncryptedEmailAddress( $addressToEncrypt, $eeaOptions ); // Output the encrypted address/link echo $encryptedAddress; ?>
But i still can't figure out where that code should go:
<?php Loader::library('eea', 'pmw_encrypted_email_address'); ?>
Sorry for being so stupid... at least this thread maybe help others too.
Michael
No problem, Michael. No question is stupid.
The "Loader::library()" line also goes in the footer.php file. Somewhere near the top is just fine, although anywhere before you invoke "new PmwEncryptedEmailAddress()" will work.
That line loads the required PHP class which allows you to instantiate a new encrypted address with the "new PmwEncryptedEmailAddress()" call.
Let me know if that helps, and don't hesitate to ask any other questions.
Regards,
-Steve
The "Loader::library()" line also goes in the footer.php file. Somewhere near the top is just fine, although anywhere before you invoke "new PmwEncryptedEmailAddress()" will work.
That line loads the required PHP class which allows you to instantiate a new encrypted address with the "new PmwEncryptedEmailAddress()" call.
Let me know if that helps, and don't hesitate to ask any other questions.
Regards,
-Steve
Thank you so much for your patience, Steve.
I did everything as you described above. Still doesn't work...
Adding this code snippet to the header of the header.php of my theme
results in the following error, when i try to log in as admin:
Fatal error: Call to a member function javascript() on a non-object in /***/***/elements/header.php on line 14
(Line 14 is the line of the added code).
Michael
I did everything as you described above. Still doesn't work...
Adding this code snippet to the header of the header.php of my theme
<?php $this->addHeaderItem( $html->javascript( 'eea.min.js', 'pmw_encrypted_email_address')); ?>
results in the following error, when i try to log in as admin:
Fatal error: Call to a member function javascript() on a non-object in /***/***/elements/header.php on line 14
(Line 14 is the line of the added code).
Michael
Change the code in header.php to...
In other words, add the first line above. That loads the needed C5 helper file.
-Steve
$html = Loader::helper('html'); $this->addHeaderItem( $html->javascript( 'eea.min.js', 'pmw_encrypted_email_address'));
In other words, add the first line above. That loads the needed C5 helper file.
-Steve
It would be AMAZING if you added this functionality to the standard Content block... to create an enhanced Content block. The idea would be to scan for any mailto:'s and replace the addresses with encrypted ones.
This is a standard feature of some other CMS's. Maybe the C5 team would be willing to buy your work and incorporate it themselves...
This is a standard feature of some other CMS's. Maybe the C5 team would be willing to buy your work and incorporate it themselves...
Right, it's a default feature of TYPO3, for example. I would also love to see email encryption for C5 working globally!
Michael
Michael
> It would be AMAZING if you added this functionality to the standard Content block...
Believe it or not, I've been toying with that notion. Actually, if I do it, I will create a new type of content block that uses a different editor because I'm not all that happy with Tiny MCE. I'm not saying this will happen for sure, bit it's good to know there's some interest in it. Thanks for your comments.
On a somewhat related note, I will soon be submitting a new package to the marketplace which takes advantage of the Encrypted E-Mail Address block if it's installed. I will announce it when it's available, but it takes at least a week to get through the marketplace review process.
Regards,
-Steve
Believe it or not, I've been toying with that notion. Actually, if I do it, I will create a new type of content block that uses a different editor because I'm not all that happy with Tiny MCE. I'm not saying this will happen for sure, bit it's good to know there's some interest in it. Thanks for your comments.
On a somewhat related note, I will soon be submitting a new package to the marketplace which takes advantage of the Encrypted E-Mail Address block if it's installed. I will announce it when it's available, but it takes at least a week to get through the marketplace review process.
Regards,
-Steve
> I will soon be submitting a new package to the marketplace
> which takes advantage of the Encrypted E-Mail Address block if it's installed.
Just to follow through on this, my new block is now available...
http://www.concrete5.org/marketplace/addons/enhanced-user-list/...
-Steve
> which takes advantage of the Encrypted E-Mail Address block if it's installed.
Just to follow through on this, my new block is now available...
http://www.concrete5.org/marketplace/addons/enhanced-user-list/...
-Steve
After all works nicely now for me - thanks to Steve's precious help - i want to provide a brief summary of what has to be done to implement Steve's email encryption add-on into a theme:
The 1st code snippet goes in the head section of header.php of the theme:
The 2nd code snippet goes anywhere in the html body of the theme (but always before the 3rd code snippet):
The 3rd code snippet goes where the encrypted email adress should appear, anywhere in the html body of the theme (but always after the 2nd code snippet):
I hope this is of interest for others who want to use this add-on directly in a theme, e.g. for email-links at the footer of a website.
Michael
The 1st code snippet goes in the head section of header.php of the theme:
<?php // Load the C5 HTML helper object $c5HtmlHelper = Loader::helper('html'); // Add the EEA JavaScript to the document head $this->addHeaderItem( $c5HtmlHelper->javascript('eea.min.js', 'pmw_encrypted_email_address')); ?>
The 2nd code snippet goes anywhere in the html body of the theme (but always before the 3rd code snippet):
<?php // Need to load EEA class only once within a given PHP file Loader::library('eea', 'pmw_encrypted_email_address'); ?>
The 3rd code snippet goes where the encrypted email adress should appear, anywhere in the html body of the theme (but always after the 2nd code snippet):
<?php $addressToEncrypt = 'email@adress.com'; $eeaOptions = array( 'isLink'=> 1, // 0 to display address only - i.e. no hyperlink 'subj' => 'Web Inquiry', 'body' => 'Details of inquiry...', 'text' => 'contact us' ); // Encrypt the address with supplied options $encryptedAddress = new PmwEncryptedEmailAddress( $addressToEncrypt, $eeaOptions ); // Output the encrypted address/link echo $encryptedAddress; ?>
I hope this is of interest for others who want to use this add-on directly in a theme, e.g. for email-links at the footer of a website.
Michael
Absolutely there's a way to do that. It's how I use it on a client's site as well. In fact, either of two approaches should work.
1) Developer API Method - This is simply a matter of loading both the Encrypted E-Mail Address (EEA) PHP class file and JavaScript file from your PHP code and then creating an instance of the EEA class. It does not make use of the block UI. I'd suggest loading the JS from your theme's header.php file like this...
That ensures that the JS will be loaded on every page of the site. Then in your theme's footer.php, do like this...
That's it. The other method is as follows...
2) Global Scrapbook Method - Create an EEA block in your global scrapbook. Give it a name. Then, in your theme's footer.php file, load that block...
I'd recommend the first approach. If you have any other questions or problems, let me know.
-Steve