• Hi all got a problem – I have a twitter feed which is sitting within a div and I’m trying to target the link portion of it so that it sits inside the box properly but in Safari its not doing so it’s just running horizontally across and breaking right out of the div that its in. I tried targeting it with css but I’m still not finding what the solution is for it. here is what I’m working with –

    @media screen and (-webkit-min-device-pixel-ratio:0)
    {
    .twitterfeed ul li a{
    width:300px;
    margin-top:20px;
    /*z-index:14px;*/

    }

    Here is the HTML/DIV coding

    <div class="twitterfeed"><!--posting of twitter feed on page-->
    <ul><li>Plz read why a white chick wud make a movie about thugs. <a href="http://www.yomaggie.com/category/themakingofplayerhating/">http://www.yomaggie.com/category/themakingofplayerhating/</a></li>
    </ul>
    </div><!--end twitterfeed div-->

    Also here is the link LINK

Viewing 3 replies - 1 through 3 (of 3 total)
  • It is over extending the div because there is no break in the url.(not just Safari)

    You can either set the .twitterfeed to overflow:hidden; which would just hide anything wider but not look so great OR you could use php to truncate the url.
    For example(if you can edit code comfortably):

    $url_length = strlen($the_url);
    if ( $url_length > 15 ) {
    $url_length_trunc = substr($the_url, 0, 14);
    $url_length_trunc = $url_length_trun . '...';
    }

    Then simply use <?php echo $url_length_trunc; ?> where you want the link displayed.

    Note: “15” Is the number of characters you will have displayed before adding “…”.

    Thread Starter junkhed1

    (@junkhed1)

    Hi racer x thanks for the reply –

    I’m familiar with php but still learning the environment –
    would you mind if I ask : where would I place the above code –

    $url_length = strlen($the_url);
    if ( $url_length > 15 ) {
    $url_length_trunc = substr($the_url, 0, 14);
    $url_length_trunc = $url_length_trun . '...';
    }

    and then where where would the
    <?php echo $url_length_trunc; ?> go

    the reason I ask is because this is the php code which is generating the twitter feed onto the page – and this coding is sitting in the
    .twitterfeed -DIV

    <?php
    $username = "yo_maggie";
    $num = 1;
    
    $feed = "http://search.twitter.com/search.json?q=from:" . $username . "&rpp=" . $num;
    
    $newfile = dirname(__FILE__)."/twitternew.json";
    $file = dirname(__FILE__)."/twitter.json";
    
    copy($feed, $newfile);
    
    $oldcontent = @file_get_contents($file);
    $newcontent = @file_get_contents($newfile);
    
    if($oldcontent != $newcontent) {
    copy($newfile, $file);
    }
    $tweets = @file_get_contents($file);
    
    $tweets = json_decode($tweets);
    
    echo "<ul>";
    for($x=0;$x<$num;$x++) {
    $str = ereg_replace("<a href="http://codex.wordpress.org/:alpha:">:alpha:</a>+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\">\</a>", $tweets->results[$x]->text);
    $pattern = '/[#|@][^\s]*/';
    preg_match_all($pattern, $str, $matches);	
    
    foreach($matches[0] as $keyword) {
    $keyword = str_replace(")","",$keyword);
    $link = str_replace("#","%23",$keyword);
    $link = str_replace("@","",$keyword);
    if(strstr($keyword,"@")) {
    $search = "<a href=\"http://twitter.com/$link\">$keyword</a>";
    } else {
    $link = urlencode($link);
    $search = "<a href=\"http://twitter.com/#search?q=$link\" class=\"grey\">$keyword</a>";
    }
    $str = str_replace($keyword, $search, $str);
    }
    
    echo "<li>".$str."</li>\n";
    }
    echo "</ul>";
    ?>

    Thanks again hope this makes sense.

    Thread Starter junkhed1

    (@junkhed1)

    Hi racer x the code below is what’s being used to generate the twitter feed on the page. Would I use the code you provided along with it or could I edit some area in the code provided where it would assist in making the link break if its too long?

    thanks again for the assistance.

    <?php
    $username = "yo_maggie";
    $num = 1;
    
    $feed = "http://search.twitter.com/search.json?q=from:" . $username . "&rpp=" . $num;
    
    $newfile = dirname(__FILE__)."/twitternew.json";
    $file = dirname(__FILE__)."/twitter.json";
    
    copy($feed, $newfile);
    
    $oldcontent = @file_get_contents($file);
    $newcontent = @file_get_contents($newfile);
    
    if($oldcontent != $newcontent) {
    copy($newfile, $file);
    }
    $tweets = @file_get_contents($file);
    
    $tweets = json_decode($tweets);
    
    echo "<ul>";
    for($x=0;$x<$num;$x++) {
    $str = ereg_replace(":alpha:+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\">\</a>", $tweets->results[$x]->text);
    $pattern = '/[#|@][^\s]*/';
    preg_match_all($pattern, $str, $matches);	
    
    foreach($matches[0] as $keyword) {
    $keyword = str_replace(")","",$keyword);
    $link = str_replace("#","%23",$keyword);
    $link = str_replace("@","",$keyword);
    if(strstr($keyword,"@")) {
    $search = "<a href=\"http://twitter.com/$link\">$keyword</a>";
    } else {
    $link = urlencode($link);
    $search = "<a href=\"http://twitter.com/#search?q=$link\" class=\"grey\">$keyword</a>";
    }
    $str = str_replace($keyword, $search, $str);
    }
    
    echo "<li>".$str."</li>\n";
    }
    echo "</ul>";
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Link breaking Div?’ is closed to new replies.