Facebook share text - php

I have these links on my site
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/4')" target="_blank" style="text-decoration:none;"></a>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/5')" target="_blank" style="text-decoration:none;"></a>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/8')" target="_blank" style="text-decoration:none;"></a>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/9')" target="_blank" style="text-decoration:none;"></a>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/10')" target="_blank" style="text-decoration:none;"></a>
with this javascript
<script>
function fbs_click(location_place) {
u=location_place;
t=document.title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
</script>
and i want to know if there is a way to add text or some sort to each one uniquely so that each link as a different body ..here is my code working but where and how do i add a description of some sort

You should add Open Graph tags to the pages that you wish to share - that's how the sharer picks them up, and the nice thing is that if someone decides to just share a link in their feed the same information is picked up. The Facebook URL Linter is a great tool for figuring out what Facebook sees when it's looking for Open Graph information.

Edit: Read the OP wrong...
As far as I know/have found, you can't adjust the body text of what gets displayed in the share dialog using facebook.com/sharer.php. You may have to look into the other methods of social interaction with facebook api.

If my memory is good, you can add a parameter in the facebook.com/sharer.php? url like so :
facebook.com/sharer.php?u=yourlinke&t=The text you want it to be in the textarea

Related

unable to change image for facebook sharing

I am using facebook sharing through facebook sharer , everything is working fine except the image share, by default it is taking the logo image but i want different image.
here is the code which I am using
<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[url]=<?php echo $fb_url; ?>', 'sharer', 'toolbar=0,status=0,width=548,height=325');" href="javascript: void(0)"> <span><i class="fa fa-facebook" aria-hidden="true"></i></span> </a>
Any kind of suggestion would be highly appreciated, Thanks for reply in advance in comment box.

Facebook share only certain div

So I have the following code for facebook share.
<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>" class="post_share_facebook" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=220,width=600');return false;">
<i class="icon-facebook"></i>
</a>
Right now, when the share button is clicked, the whole snapshot of the page is shown on the share window.
On a php file where this share button is located, I have a specific div which I want to show on the Facebook share window instead of the whole snapshot of the page.
Does anyone know how I can do this?
Thanks!
Not sure if its possible that way, you can try <?php the_permalink(); ?>#your_div_id
Another alternate would be using open graph

dynamically apply title of html document into the title fields of images

Good day.
I am wondering is there any short script to apply the actual page title into the image title? So if I have this page title in my head section:
<head>
<title>Dogs</title>
</head>
and these images:
<a class="sth" href="#" title="PROBLEM"><img src="img01.jpg" alt="sth"/></a>
<a class="sth" href="#" title="PROBLEM"><img src="img02.jpg" alt="sth"/></a>
<a class="sth" href="#" title="PROBLEM"><img src="img03.jpg" alt="sth"/></a>
I want to dynamically apply the title where it says "PROBLEM" from the page title. What is the easiest way of doing this? Does it need to be in php or can it be in javascript?
I just want "Dogs" to go in the place where "PROBLEM" is at the moment if you know what I mean. So probably "PROBLEM" needs to be replaced by a simple script. The document must remain a html by the way.
var title = document.title;
$('.sth').attr('title',title);
Edit, but I don't really see the point of doing this. The title of the site has little to do with the images, if it's added to all of them, what is the point anyways?
in your head part use
<?php
$title_set = "Dogs";
echo "<title>$title_set</t?>itle>";
?>
Every where where you have images use this
<a class="sth" href="#" title="
<?php
echo $title_set;
?>
"><img src="img01.jpg" alt="sth"/></a>
Please remember to change $title_set for each page, or it will be set for every page.
Why couldn't you do this in PHP?
PHP
$title = "Dogs";
HTML
<a class="sth" href="#" title="<?php echo $title; ?>"><img src="img01.jpg" alt="sth"/></a>
<a class="sth" href="#" title="<?php echo $title; ?>"><img src="img02.jpg" alt="sth"/></a>
<a class="sth" href="#" title="<?php echo $title; ?>"><img src="img03.jpg" alt="sth"/></a>
So set a var in PHP, and echo it where you want it to be shown.
PHP would be best so it renders as it should right from the start of the page load (Also so search engines can crawl it). You can do it via javascript, but this may cause dodgy results with SEO.
If you can, always do stuff like this in PHP (Or whatever server side language you code in), unless you absolutely have no other choice to use javascript.

How to show files in iframe by Jquery or JavaScript and prevent to show in another page loading?

Here is my problem, I had describe in code project. When I am clicking in an icon it try to open in new page for showing image or pdf or video. But, I don't like this. I like to show that files in my iframe in same page. How can I do this ?
My code project link is:
Please don't open in new page. Just stay in same page.
I could suggest using a plugin as it makes things easier.
http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/
Alternatively what you want is to change the iframe src.
Using jQuery, you could for example, do something like this
<iframe id="myframe" style="display:none" width="630" height="420"></iframe>
<div class="fileIcon">
<a class="click" onClick="" rel="gallery" href="#">
<img src="src" title="" width='100' height='100' alt="" />
</a>
</div>
And JS
$('a').click(function(e){
e.preventDefault()
var s = $(this).find('img').attr('src');
$('#myframe').attr('src', s).show();
});
FIDDLE
This will get the image src and more it to the iframe
Give your iframe a name="myframe" then in your target you would use target="myframe"

PHP & Jquery - open a small div over others div when mouse go on a link

i need to open a div (or somethings other, dunno what) when mouse go on a link. But this div doesnt move other div. It must open OVER the others div (like this website...when there are the "popup/error" div over others div. How can do it? Transparent? Or somethings like it?
for example, if i write somethings into title field in a link statement, there is a small windows that show to me what i wrote. somethings like it, but with a div, or somethings other when i can put text, image, ecc.
as another example, on facebook when i go on the main wall and i go with mouse on the name of the users, it show me a small windows with more details. the same when i open the chat box :)
code :
<div class="playerDetailsOff">
Name : Marco<br />
Surname : Daghine
</div>
<a class="viewt" href="#" onmouseover="viewPlayerOn('id1?>');return false" onmouseout="viewPlayerOff();return false">link 1</a>
<a class="viewt" href="#" onmouseover="viewPlayerOn('id2?>');return false" onmouseout="viewPlayerOff();return false">link 2</a>
<a class="viewt" href="#" onmouseover="viewPlayerOn('id3?>');return false" onmouseout="viewPlayerOff();return false">link 3</a>
<a class="viewt" href="#" onmouseover="viewPlayerOn('id4?>');return false" onmouseout="viewPlayerOff();return false">link 4</a>
function viewPlayerOn(val) {
$('.playerDetailsOff').removeClass().addClass('playerDetailsOn');
}
function viewPlayerOff() {
$('.playerDetailsOn').removeClass().addClass('playerDetailsOff');
}
.playerDetailsOn{width:200px; height:100px; position:fixed;}
.playerDetailsOff{display:none;}
Basically what you want is an overlay or a lightbox (both terms are easy to google). Just as Felix Kling pointed out you will want absolute positioning - or you can look at z-index (highest z-index is on top).
Just to make it easy on you there was a similar question with example code which should definitely get you started: jQuery - How Do I Place a DIV On Overlay?
You want overLIB. Check out their homepage to see features and documentation.
Regards, Alin
You can use this one: http://www.leigeber.com/2008/06/javascript-tooltip/. It is a lightweight javascript if you don't want to use JQuery.

Categories