Links To Posting Page From DataTable

Links To Posting Page From DataTable

BiggestBadDaddyBiggestBadDaddy Posts: 6Questions: 0Answers: 0
edited March 2011 in General
Hello World

I'm trying to have links in the DataTable's content (server_side) that would link to the posting page with all the details, similar to Craigslist. Does anyone know how to do this, or has done this? Any help would be greatly appreciated as I have over 3,000 postings loading at once right now...not very user-friendly. :-o

I'm also trying to get the data to load descending from most recent.

Thanks!

Replies

  • allanallan Posts: 63,112Questions: 1Answers: 10,395 Site admin
    You can just add HTML to the JSON return for your column which includes the link tag you want. If you have a look at line 162 in this example: http://www.datatables.net/development/server-side/php_mysql - you can see how you can add special formatting for a given column.

    Allan
  • BiggestBadDaddyBiggestBadDaddy Posts: 6Questions: 0Answers: 0
    Thanks for the response Allan. I apologize, but I'm not following how to add the html to the code.

    I want both the listing ID and the listing TITLE to be hyperlinks to the listing page for SEO purposes, as well as the entire row to be click-able, which, to my knowledge, doesn't appear to the spiders like the text links do. This is what have now on the data table I wrote:

    [code]
    >
    <?php echo $id; ?>
    <?php echo $title_one; ?>, <?php echo $title_two; ?>
    <?php echo $photoYes; ?>

    [/code]
  • allanallan Posts: 63,112Questions: 1Answers: 10,395 Site admin
    To modify my example to add a link to Google for the version column you can just do this (again at line 162):

    [code]
    $row[] = ''. $aRow[ $aColumns[$i] ] .'';
    [/code]
    That's the basic idea of how you can format the string for the return.

    Allan
  • BiggestBadDaddyBiggestBadDaddy Posts: 6Questions: 0Answers: 0
    You are super cool, thank you so much. I'll give this a try this afternoon.
    Thanks.
  • BiggestBadDaddyBiggestBadDaddy Posts: 6Questions: 0Answers: 0
    Hi Allan
    I tried the example you provided, unfortunately I kept getting the JavaScript error. I even tried to copy and paste the entire code and replace my database with the one in the example and still got the error.
    Not sure how to fix this.
    Thanks
  • allanallan Posts: 63,112Questions: 1Answers: 10,395 Site admin
    What is the error?
  • BiggestBadDaddyBiggestBadDaddy Posts: 6Questions: 0Answers: 0
    [code]
    while ( $aRow = mysql_fetch_array( $rResult ) )
    {
    $sOutput .= "[";
    for ( $i=0 ; $i
  • allanallan Posts: 63,112Questions: 1Answers: 10,395 Site admin
    I think both examples are saying what the issues is and where to start debugging. So with your own code (which is probably what you want more than mine :-) ) have a look at the JSON return from the server. The error is saying that it is not valid, so it stands to reason that there is an issue with the return (you can run it through http://jsonlint.com to check it). Looking at the return in Firebug will help.

    Allan
  • BiggestBadDaddyBiggestBadDaddy Posts: 6Questions: 0Answers: 0
    Will do, thanks for the help.
This discussion has been closed.