gum1982 Posted October 11, 2009 Share Posted October 11, 2009 Hello can someone please help me i need to setup some shortcode here is the code that i what as shortcode. <a href="<?php echo c2c_get_custom('main image'); ?>" rel="lightbox" title="<?php echo c2c_get_custom('title'); ?>"><img src="<?php echo c2c_get_custom('thumb'); ?>" width="60" height="45" alt="df" /></a> Ive been looking at smashing magazines shortcode and come up with this. function insert() { return '<a href="<?php echo c2c_get_custom('main image'); ?>" rel="lightbox" title="<?php echo c2c_get_custom('title'); ?>"><img src="<?php echo c2c_get_custom('thumb'); ?>" width="60" height="45" alt="df" /></a>'; } add_shortcode('image', 'insert'); but i get errors im a newbie to php and would really appreciate some help. Or a push in the right direction. Do i need to escape all the " and ' are they clashing? Quote Link to comment https://forums.phpfreaks.com/topic/177341-escaping/ Share on other sites More sharing options...
Dorky Posted October 11, 2009 Share Posted October 11, 2009 you have the right idea, just backwards. you need to use the double quotes in your php but replace doubles with singles in your html and jscript. Quote Link to comment https://forums.phpfreaks.com/topic/177341-escaping/#findComment-935046 Share on other sites More sharing options...
gum1982 Posted October 11, 2009 Author Share Posted October 11, 2009 ah right ok thanks for the reply i will give this a try now so am i right in thinking this is correct. function insert() { return '<a href='<?php echo c2c_get_custom("main image"); ?>' rel='lightbox' title='<?php echo c2c_get_custom("title"); ?>'><img src='<?php echo c2c_get_custom("thumb"); ?>' width='60' height='45' alt='df' /></a>'; } add_shortcode('image', 'insert'); Quote Link to comment https://forums.phpfreaks.com/topic/177341-escaping/#findComment-935048 Share on other sites More sharing options...
mikesta707 Posted October 11, 2009 Share Posted October 11, 2009 is that a php function? if so you are getting errors because you are trying to open php tags in php tags. why are you doing that? and yes the multiple closing/opening single quotes are coinciding. Next time put code in code tags function insert() { return '<a href="'.c2c_get_custom("main image").'" rel="lightbox" title='".echo c2c_get_custom("title")."'><img src='".c2c_get_custom("thumb")."' width="60" height="45" alt="df" /></a>'; } Quote Link to comment https://forums.phpfreaks.com/topic/177341-escaping/#findComment-935068 Share on other sites More sharing options...
Dorky Posted October 11, 2009 Share Posted October 11, 2009 lol, wow. i overlooked it an at a glance assumed jscript. yeah dude escaping is to make it easier to place $var inline with html. Escaping 101 standard html<div id="whatever"> escaped html<div id=/"whatever/"> shortcut html<div id='whatever'> is that a php function? if so you are getting errors because you are trying to open php tags in php tags. why are you doing that? and yes the multiple closing/opening single quotes are coinciding. Next time put code in code tags function insert() { return '<a href="'.c2c_get_custom("main image").'" rel="lightbox" title='".echo c2c_get_custom("title")."'><img src='".c2c_get_custom("thumb")."' width="60" height="45" alt="df" /></a>'; } Quote Link to comment https://forums.phpfreaks.com/topic/177341-escaping/#findComment-935088 Share on other sites More sharing options...
mikesta707 Posted October 11, 2009 Share Posted October 11, 2009 oops sorry syntax error function insert() { return '<a href="'.c2c_get_custom("main image").'" rel="lightbox" title="'.c2c_get_custom("title").'"><img src="'.c2c_get_custom("thumb").'" width="60" height="45" alt="df" /></a>'; } Quote Link to comment https://forums.phpfreaks.com/topic/177341-escaping/#findComment-935089 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.