Dynamic Related News

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Moderator: Spunkmeyer

Postby bozoka45 » Tue Mar 15, 2005 7:44 am

Well, your links aren't working, I can tell you that much.

You'd have to pass the newsid along in the query string to the script, and then in the SQL code, put (assuming newsid is the GET variable):

Code: Select all
AND `newsid`!= '" . $_GET['newsid'] . "'
User avatar
bozoka45
 
Posts: 1159
Joined: Sun Mar 23, 2003 8:38 pm
Location: New Orleans

Postby bozoka45 » Tue Mar 15, 2005 7:48 am

kriko wrote:a) Why do you use a function (dbConnect()) to connect to the mySQL database when you only call it once?


Because that really isn't how it is in my code, I use it differently. This is a modified version for public release.

b) First you declare $SearchSQL as a string (='';) then later on you add values to it like it was an array... PHP is relatively loose about these things, but it will issue a notice in a development platform. I'd reccommend writing code that follows all the requirements and standards. Therefore you should declare $SearchSQL as an array:
$SearchSQL = array();

c) Try using this line for $search:
Code: Select all
$search = explode(" ",stripslashes(urldecode($_REQUEST['s'])));


d) And the following for appending new items to the SearchSQL array:
Code: Select all
$SearchSQL[] = "SELECT * FROM `" . addslashes($newstable) . "` WHERE `" . addslashes($field) . "` LIKE '%" . addslashes($s) . "%'";



Thanks for the suggestions.

f) I didn't really get the point of this line:
Code: Select all
($results['xMultiSubmitSP'] == '69421072513396')

Wouldn't it only work on your installation?!


Yeah, its part of my style, which is unique to my installation.
User avatar
bozoka45
 
Posts: 1159
Joined: Sun Mar 23, 2003 8:38 pm
Location: New Orleans

Postby bozoka45 » Tue Mar 15, 2005 7:49 am

tkaplan06 wrote:The other problem I am having is the script is printing the keywords that are specified in the custom field I have created right above the related links. How can I stop it from doing this?


Sounds like you need to fix your style, but I'm not quite sure what your code looks like...
User avatar
bozoka45
 
Posts: 1159
Joined: Sun Mar 23, 2003 8:38 pm
Location: New Orleans

Postby tkaplan06 » Fri Mar 18, 2005 12:57 am

bozoka45 wrote:Well, your links aren't working, I can tell you that much.

You'd have to pass the newsid along in the query string to the script, and then in the SQL code, put (assuming newsid is the GET variable):

Code: Select all
AND `newsid`!= '" . $_GET['newsid'] . "'


Where do you place this code in the SQL code? Thanks so much for your help!
tkaplan06
 
Posts: 9
Joined: Wed Mar 09, 2005 2:28 am

Postby tkaplan06 » Fri Mar 18, 2005 1:17 am

Here is what I have in the style:

Code: Select all
<?php
$search = "<Field: CustomField_Keywords>";
$search = urlencode($search);
include ( 'http://www.arcticwebdesign.com/~choate/related.php?s=' . $search);
?>
tkaplan06
 
Posts: 9
Joined: Wed Mar 09, 2005 2:28 am

Postby bozoka45 » Fri Mar 18, 2005 2:00 am

Change this:

Code: Select all
$SearchSQL[] = "SELECT * FROM `" . $newstable . "` WHERE `" . $field . "` LIKE '%" . $s . "%'";


To this:

Code: Select all
$SearchSQL[] = "SELECT * FROM `" . $newstable . "` WHERE `" . $field . "` LIKE '%" . $s . "%' AND `newsid`!= '" . $_GET['newsid'] . "'";


Not the Coranto Style, the style you made within the PHP script.
User avatar
bozoka45
 
Posts: 1159
Joined: Sun Mar 23, 2003 8:38 pm
Location: New Orleans

Postby tkaplan06 » Sun May 01, 2005 5:17 pm

Thanks for all your help. We have this up and running beautifully. However, I have two questions still.

1. How can we limit the number of related articles that are returned?

2. The script is printing the current article as one of the related articles, which is a little weird. How can we prevent that?

Here is the code I have for the script:

Code: Select all
//Count the results with rcount
$rcount = 0;


//Formating section starts here!
//I've left the formatting I have in order to help you.

//Image this part as what goes about the <Field: Content> in a template

$relatedHTML = "<font face=\"Arial\" size=\"1\">";
//$relatedHTML .= "" . urldecode($_REQUEST['s']) . "\n";

$unrelatedHTML = "None available";
//Now, this is where the style goes.

while($results=mysql_fetch_array($query)) {
            $relatedHTML .=  "<a href=\"" . $results['newsid'] . ".php\">" . $results['Subject'] . "<br>\n";
            $rcount++;
         }
     

//And finally, this is below the <Field: Content> in a template

$relatedHTML .= "</font>\n";

//This will only dispaly your result box if at least one result is returned.

if($rcount > 0) {
   print $relatedHTML;
}
   
if($rcount = 0) {
   print $unrelatedHTML;   
}

?>


Thanks in advance for your help!!
Tom
tkaplan06
 
Posts: 9
Joined: Wed Mar 09, 2005 2:28 am

Postby bozoka45 » Sun May 01, 2005 6:33 pm

tkaplan06 wrote:Thanks for all your help. We have this up and running beautifully. However, I have two questions still.

1. How can we limit the number of related articles that are returned?


Within the while statement, put something like this:

Code: Select all
if($rcount == 'MAX VALUE') {
break;
}


2. The script is printing the current article as one of the related articles, which is a little weird. How can we prevent that?


You'd have to pass the newsid was one of the GET variables (in the url, like newsid=<Field: newsid>) and in the SQL, add this:

Code: Select all
AND `newsid` != '" . $_GET['newsid'] . "'
User avatar
bozoka45
 
Posts: 1159
Joined: Sun Mar 23, 2003 8:38 pm
Location: New Orleans

Postby web » Thu Sep 15, 2005 2:49 pm

I was trying your code. Made related.php in root directory/ then in style wrote
(tryied to write in tmpl too)

Code: Select all
<?php
$search = "<Field: Subject>";
$search = urlencode($search);
include ( 'http://' . $_SERVER['HTTP_HOST'] . '/related.php?s=' . $search);
<close php tag>


but it doesn't work. It give nothing. what i'm doing wrong?

I'm using Coranto 1.24 and CorantoSQL
User avatar
web
 
Posts: 176
Joined: Sun Nov 30, 2003 3:39 pm

Postby bozoka45 » Thu Sep 15, 2005 10:29 pm

You need to be a little more descriptive than "It doesn't work." There could be a 1000 things wrong. Does Coranto actually create the file itself, have you looked at the source code of the created Coranto file?
User avatar
bozoka45
 
Posts: 1159
Joined: Sun Mar 23, 2003 8:38 pm
Location: New Orleans

Postby SrNupsen » Thu Sep 15, 2005 10:39 pm

And last but not least (sorry, but I have to ask): Are you actually using

Code: Select all
<close php tag>


in that code?

SrNupsen
-----------------------------------------------------------------------------------------------------
Coranto is free software. I am available for custom work or troubleshooting.

http://www.sundaune.no - transkripsjon, webdesign, nettsider, tekstbyrå
http://www.vagbladet.no - satire, politikk, kultur, sport, nettavis
-----------------------------------------------------------------------------------------------------
SrNupsen
 
Posts: 2229
Joined: Tue Jan 09, 2007 6:46 pm
Location: Nesodden, outside Oslo, Norway

Postby bozoka45 » Fri Sep 16, 2005 1:47 am

SrNupsen wrote:And last but not least (sorry, but I have to ask): Are you actually using

Code: Select all
<close php tag>


in that code?

SrNupsen


Good question. I didn't even think to ask.
User avatar
bozoka45
 
Posts: 1159
Joined: Sun Mar 23, 2003 8:38 pm
Location: New Orleans

Postby web » Fri Sep 16, 2005 4:17 pm

using
Code: Select all
<?php
$search = "<Field: Subject>";
$search = urlencode($search);
include ( 'http://localhost/related.php?s=' . $search);
<close php tag>


profile generates clear sheet

using
Code: Select all
<?php
$search = "<Field: Subject>";
$search = urlencode($search);
include ( 'http://localhost/related.php?s=' . $search);
?>

profile generates news but without any related news

in the generated code no signs of any code
User avatar
web
 
Posts: 176
Joined: Sun Nov 30, 2003 3:39 pm

Postby bozoka45 » Fri Sep 16, 2005 4:21 pm

Code: Select all
<?php
$search = "<Field: Subject>";
$search = urlencode($search);
include ( 'http://localhost/related.php?s=' . $search);
?>


This is what you want to use.

It could not be generating any related news because you don't have any. You are looking at the page before it's process by the server, right? Not afterwards.
User avatar
bozoka45
 
Posts: 1159
Joined: Sun Mar 23, 2003 8:38 pm
Location: New Orleans

Postby web » Fri Sep 16, 2005 4:36 pm

I have added some identical news. It must show at least one news identical to its subject
User avatar
web
 
Posts: 176
Joined: Sun Nov 30, 2003 3:39 pm

PreviousNext

Return to Customization

Who is online

Users browsing this forum: No registered users and 1 guest

cron