Quote from: valokammi at Mar 11, 2011, 01:45 PM
Tryied this one but got parsing error:
`[*id*]` is not numeric and may not be passed to makeUrl()
Lots of time gone since topic started v. 1.0.1, now evo v. 1.0.5
Ok, this is going to seem an inelegant hack to most I’m sure but I was trying to make a share icon for LinkedIn and was getting the error mentioned above.
Here is my hack to get round it (Evo) and also the LinkedIn share link solution as well.
Regarding addressing the "`[*id*]` is not numeric and may not be passed to makeUrl()" error:
This suggested the document id number is not getting through so I hacked the [[ThisPageUrl]] snippet code with the documentObject function to get the document id and force it into the equation.
New snippet
<?php
//Let's force the document ID to be inserted into the makeURL function using documentObject function
$docInfo = $modx->documentObject['id'];
//Note: If you are copying this to use with your own site make sure you change "prefix_" to whatever your database table prefix is
$result = $modx->db->query( "SELECT prefix_site_content.id FROM prefix_site_content WHERE prefix_site_content.id = '$docInfo'" );
//Note: the original snippet used a variable called "$id" and I have made my variable "$id2" because I am extremely creative :-D
$id2 = '';
while( $row = $modx->db->getRow( $result )) {
$id2 .= $row['id'];
}
//Make sure you use the new variable here otherwise the problem won't be solved
$url = urlencode($modx->makeUrl($id2, '', '', 'full'));
return $url;
?>
Ok so if you’re with me the LinkedIn code solution went nicely into a chunk called "{{linkedin-share}}" shown below
<a href="http://www.linkedin.com/shareArticle?mini=true&url=[[ThisPageURL?]]&title=[*pagetitle*]&source=[(site_name)]" target="_blank">
<img style="vertical-align:middle;" src="http://www.yourdomain.com/path-to-image/icon-linkedin-page.png" title="Share on LinkedIn" alt="LinkedIn" width="16" height="16"></a>
Hope this helps anyone else with a similar situation (I’ve even attached a logo you can use) - let me know if it does.
All the best and keep up the good work everyone!