PDA

View Full Version : sponsored links, logged clicks...


JÿGius³
12-12-2003, 08:01 AM
Hi people :)

I've implemented some features. All the code is in
phpdig-1.6.5.zip
For each modification I've provided the line number.

1) search.php
- Added a $template_name variable in order to
avoid to put the entire template's path in form/link.

2) libs/search_function.php
- 18 Added a $template_name
- 352 Added $table_results['page_link']
onmousedown=\"return clk(".$spider_id.",this)\"
This javascript function (you can see it in template/phpdig.html)
call the php script (url.php) responsible
to log clicks as well.
- 383 Added &template_name=".trim($template_name). to $url_bar
- 453 Replaced $template with $template_name
- 458 Added sponsored links. These links are generated from
banners(). Sponsored links can be turned off with the SPONSORED_LINK
constant in includes/config.php
- 470 I've moved the page at the end of function in a separate file
called rescue_page.php; it'a a wasting time to parse it every time.
- 475 If you want sponsored links you have to implement banners().

3) libs/function_phpdig_form.php
- 36 The form method can be obtained from a FORM_METHOD constant?
- 37 Changed template_demo in template_name
- 52 Changed some form element
- 60 After a search, for each result there is a link to limit the search
to a specific site. I've added a form element for this function.

4) locales/it-language.php
- Added some little translation.

5) includes/config.php
- 17 Added the possibility to choose a template using url

6) sql/phpdig_log_click.sql
- Table to log clicks

7) template/phpdig.html
- At the beginning I've added the javascript code called when a user click
on a results link.

8) It would be nice if the logged clicks could be linked with the most searched terms.

You can compare my code with the official one with ease
using a diff tool.
Let me know if some feature is so nice to put it in the next
release.

Best regards.

JÿGius³ :angry:



ps. I've just replaced the template. I've deleted my previous attachment; when I edit the post I can't add an attachment?
Why?

JÿGius³
12-13-2003, 03:30 AM
The replaced code.

Charter
12-14-2003, 04:42 PM
Hi. Thank you for the mods. Do you have a site setup with these mods for public view?

I'm not sure about the attachment problem. Maybe once deleted it won't accept a new attachment in an edited post?

alivin70
12-18-2003, 08:27 AM
Originally posted by Charter
Hi. Thank you for the mods. Do you have a site setup with these mods for public view?

I'm not sure about the attachment problem. Maybe once deleted it won't accept a new attachment in an edited post?
Hi, me and JyGius are working together on Phpdig, so I reply on this question.

Unfortunately we haven't yet a working demo online.

Most probably our Phpdig powered website will be online after Xmas holidays.

We published our mods because is long time we are working on it and we already had to import twice our mods in the new Phpdig releases. For that reason we decided to send the code now, instead of waiting to finish all the things we are working on.

We hope you will import our mods in the next release of Phpdig so we can continue to develop new features for it.

Long time ago I suggested using a CVS server to mantain the code synchronized. Without CVS you have to manually import changes from many developers. I know it's a little tricky for you. :(

Anyway, if you have questions about our changes, pleas ask :)

edgar
12-22-2003, 02:43 PM
what have does I to make thereby the sponsoren links functioned and which must I edit exactly and which syntax?

sorry for my bad english :rolleyes:

Charter
12-26-2003, 03:51 PM
Hi. In search_function.php from the above attached file, it looks like you'd need to fill in the below function.

function banners($query_string){
///////
//////
//////
}

alivin70
12-27-2003, 03:02 AM
Originally posted by Charter
Hi. In search_function.php from the above attached file, it looks like you'd need to fill in the below function.

function banners($query_string){
///////
//////
//////
}

Yes,
you need to fill the banners function with specific queries for your ads server.

The steps are:
1) select text banners using $query_string (search keywords)
2) put the result in a string variable
3) output the html code in the template

edgar
12-27-2003, 06:45 AM
i dont unterstand :(

can you write an example

JÿGius³
12-30-2003, 07:08 AM
Hi All!

function banners($query_string){
///////
// 1-select your banner using $query_string
// 2-format your results in a string
// variable using html
// 3- return this variable
//////
}



The function is pretty simple :angel:

Best regards.

Gius

edgar
12-30-2003, 04:28 PM
i dont unterstand

alivin70
12-31-2003, 02:57 AM
Hi, let me help you with some code (very simplified):


function banners($query_string){
// 1-select your banner using $query_string
// You shoud have something like this, dependimg on your AdServer
$query_ini ='SELECT DISTINCT B.bid, B.url, B.text
FROM '.$prefix.'_banner_imp3 AS B
WHERE B.keyword LIKE \'%'.trim($query_string).'%\'';
$bresult = @mysql_query($query_ini);
// Count banner
$numrows = @mysql_num_rows($bresult);

// 2-format your results in a string
// variable using html
if ($numrows > 0) {
$html = '<b>Sonsored links</b> <br>'
while (list($bid,$url, $text)=mysql_fetch_row($bresult){
$html .="<a href=$url>$text</a><br>";
// do other things
}
}

// 3- return this variable
return $html;
}


So, you have to implement the function banners() accordingly with your AdServer (NOT present in Phpdig, try PhpAdsNew or others).

That function is called during a search and the html code is passed to the template:

search_function.php, lines around 460

if($query_string AND SPONSORED_LINKS != -1)
$banner['adbanner'] = banners($query_string);
$t_strings = array_merge($t_mstrings,$t_fstrings, $banner);
phpdigParseTemplate($template,$t_strings,$table_results);

Finally you have to print the html code in the template wherever you want

<!-- sponsored link -->
<phpdig:adbanner/>

that's all :)

RaGe
04-29-2004, 06:29 AM
So basicly this is the example content for adbanners.php?

Originally posted by alivin70
[B]Hi, let me help you with some code (very simplified):


function banners($query_string){
// 1-select your banner using $query_string
// You shoud have something like this, dependimg on your AdServer
$query_ini ='SELECT DISTINCT B.bid, B.url, B.text
FROM '.$prefix.'_banner_imp3 AS B
WHERE B.keyword LIKE \'%'.trim($query_string).'%\'';
$bresult = @mysql_query($query_ini);
// Count banner
$numrows = @mysql_num_rows($bresult);

// 2-format your results in a string
// variable using html
if ($numrows > 0) {
$html = '<b>Sonsored links</b> <br>'
while (list($bid,$url, $text)=mysql_fetch_row($bresult){
$html .="<a href=$url>$text</a><br>";
// do other things
}
}

// 3- return this variable
return $html;
}


So, you have to implement the function banners() accordingly with your AdServer (NOT present in Phpdig, try PhpAdsNew or others).

alivin70
04-29-2004, 06:53 AM
Originally posted by RaGe
So basicly this is the example content for adbanners.php?
Yes, it is.

The most simplified version of banner() contains a single query to the ads table ("text ads" if you want Google-style Sponsored links) and returns the formatted code of sponsored links.