WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Bakery Lightbox Caption with Email Link and Custom Subject
  • Print
Pages: [1]   Go Down

Author Topic: Bakery Lightbox Caption with Email Link and Custom Subject  (Read 8535 times)

Offline sky writer

  • Posts: 926
Bakery Lightbox Caption with Email Link and Custom Subject
« on: June 16, 2011, 09:30:36 PM »
I have been working toward this functionality for some time now.  I am building a website for an Art Gallery using Bakery as the gallery.  It's working very well.  Each work is shown as a thumbnail, and when clicked, opens using lightbox (actually fancybox, thanks to a great workaround by blackbird!).  The caption below the lightbox image shows the Product Name ($img_title), which contains the artist's name, artwork title, dimensions etc.

To take the usability a step further, I wanted to add an "INQUIRE" link beside each caption so that when a user clicked, it would open their email with the Product Name info in the subject line.  I found this functionality to put a hyperlink within a hyperlink on the lightbox site:
Code: [Select]
$email_caption = '<a href="mailto:curator@quinnsoftweed.ca?subject=[TITLE]">Inquire</a>';
Everything works perfectly except that most of the [TITLE] content has quotation marks and other symbols which break the functionality.

For instance: Alexis Arts "A Winters Walk" Oil 24x36"
Ends up in the Subject line as: Alexis Arts
I presume because the quotation mark is breaking something.

So I have been two days trying to learn about stripping slashes and string replacement, but nothing I have tried has worked.

If anyone can offer some guidance, it would be greatly appreciated.  If I can get this working, I will gladly put up a tutorial for others to benefit from.

Here is the affected code from Bakery view_overview.php:
Code: [Select]
$img_title = '[TITLE]';

$email_caption = '<a href="mailto:curator@quinnsoftweed.ca?subject=[TITLE]">Inquire</a>';

// Make array of all item thumbs and images
if (file_exists($thumb_dir.$thumb_file) && file_exists($img_dir.$image_file)) {

// If needed add lightbox2 link to the thumb/image...
if ($setting_lightbox2 == "overview" || $setting_lightbox2 == "all") {
$thumb_prepend = "<a href='".$img_url.$image_file."' rel='lightbox[image_".$item_id."]' title='".$img_title.$email_caption."'><img src='";
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Bakery Lightbox Caption with Email Link and Custom Subject
« Reply #1 on: June 16, 2011, 10:50:07 PM »
You should use the php function htmlspecialchars of htmlentities for the title to replace all "problem" characters.
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

Offline sky writer

  • Posts: 926
Re: Bakery Lightbox Caption with Email Link and Custom Subject
« Reply #2 on: June 17, 2011, 02:09:52 AM »
I've looked at those options but I can't find a way to make it work with my situation.

How do I use them to make the [TITLE] safe to use in the code as shown?
Logged

Offline sky writer

  • Posts: 926
Re: Bakery Lightbox Caption with Email Link and Custom Subject
« Reply #3 on: June 17, 2011, 03:35:13 AM »
Thanks Ruud for pointing me in the right direction.  I had tried those before, along with many other things.  And I didn't work at that angle too much because I wasn't sure it was the right path.  Once you told me that was the direction to go, it took some time, but I figured it out.

I will share all this when I get some time to formulate it into something understandable.

Cheers!
Logged

Offline Bug

  • Posts: 237
Re: Bakery Lightbox Caption with Email Link and Custom Subject
« Reply #4 on: June 17, 2011, 07:28:09 AM »
I am curious about the fancybox in stead of lightbox, is this taken from a post on the forum?
Logged

Offline YoJoe

  • Posts: 74
    • projektowanie stron
Re: Bakery Lightbox Caption with Email Link and Custom Subject
« Reply #5 on: June 17, 2011, 01:58:41 PM »
skywriter: try to clean the $img_title variable from any non letter/digital chars using string replace function.
The easiest way:
Code: [Select]
$specialCharacters = array(
‘#’ => ”,
‘$’ => ”,
‘%’ => ”,
‘&’ => ”,
‘@’ => ”,
‘.’ => ”,
‘€’ => ”,
‘+’ => ”,
‘=’ => ”,
‘§’ => ”,
‘\\’ => ”,
‘/’ => ”,
);

while (list($character, $replacement) = each($specialCharacters)) {
$string = str_replace($character, '-' . $replacement . '-', $string);
}

There's also a more advanced preg_replace() function, but only you know what exact chars appear in image titles.
Logged
WuJitsu - in web I trust  :cool:

Offline sky writer

  • Posts: 926
Re: Bakery Lightbox Caption with Email Link and Custom Subject
« Reply #6 on: June 17, 2011, 03:26:36 PM »
Quote from: Bug on June 17, 2011, 07:28:09 AM
I am curious about the fancybox in stead of lightbox, is this taken from a post on the forum?

Yes: https://forum.WebsiteBaker.org/index.php/topic,21322.msg143994.html#msg143994
Logged

Offline sky writer

  • Posts: 926
Re: Bakery Lightbox Caption with Email Link and Custom Subject
« Reply #7 on: June 17, 2011, 03:29:09 PM »
YoJoe - I ended up using htmlentities, as suggested by Ruud, and it worked perfectly.
Thanks for the alternate suggestion.
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Bakery Lightbox Caption with Email Link and Custom Subject
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2