News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Affiliates System

Started by Diego Andrés, December 04, 2008, 07:29:28 AM

Previous topic - Next topic

[unplugged]

Add the ssi_random_affiliates() block of code to your SSI.php as described earlier in this thread. Then you would simply add ssi_random_affiliates(12); to the SP block, where would be whatever number of banners you want to be displayed.
« Next Edit: Tomorrow at 08:34:45 PM by SunKing »   <---- « someone stole my sig... :o »



Chit-Chat ChatterBox Boss

Quote from: SunKing on June 13, 2009, 05:26:35 PM
Add the ssi_random_affiliates() block of code to your SSI.php as described earlier in this thread. Then you would simply add ssi_random_affiliates(12); to the SP block, where would be whatever number of banners you want to be displayed.
It already is in there ... and I added that to the SP block and it made it random just it kept none stop sending affiliates in random order never restarted just steady flow of affiliates.

This is in SSI

function ssi_random_affiliate($limit)
{
   global $scripturl, $smcFunc;
   
   $rand_aff = $smcFunc['db_query']('', "
      SELECT title, approved, id_affiliates, image
      FROM {db_prefix}affiliates
      WHERE  approved = 1
   ORDER BY RAND()
    LIMIT $limit",
   array(
   
   )
);

   $content = array();
   
   while ($row = $smcFunc['db_fetch_assoc']($rand_aff))
   {     
      $content[] = array(
      'title' => $row['title'],
      'image' => $row['image'],
      'id_affiliates' => $row['id_affiliates'],
      'approved' => $row['approved'],
      );   
   }
      //return $content;
     
      foreach ($content as $row)
     
      echo' <a href="' . $scripturl . '?action=affiliates;sa=out;idaff=', $row['id_affiliates'],'"><img src="'.$row['image'].'"  onload="ImageResizer.createOn(this);" alt="'.$row['title'].'"></a>';
   
}
Chit-Chat ChatterBox

Our site is open to everyone. It is a resource for anyone and everyone to talk about anything and everything you could possibly think of. It's a great place to come and talk, ask questions, or just simply hang out. We offer many great features. All we ask is that you follow by the site rules. Hope to see you around!
www.chitchatchatterbox.com
Remember in the "Referral" box to put "Caleb" while registering.

SA™

post up you ssi.php please
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Chit-Chat ChatterBox Boss

This random add works fine on the board index of the affiliates banners just the SP is giving problems.

Chit-Chat ChatterBox

Our site is open to everyone. It is a resource for anyone and everyone to talk about anything and everything you could possibly think of. It's a great place to come and talk, ask questions, or just simply hang out. We offer many great features. All we ask is that you follow by the site rules. Hope to see you around!
www.chitchatchatterbox.com
Remember in the "Referral" box to put "Caleb" while registering.

SA™

hmm never tried it with sp try just creating a php block and just add this

global $scripturl, $smcFunc;
   
   $rand_aff = $smcFunc['db_query']('', "
      SELECT title, approved, id_affiliates, image
      FROM {db_prefix}affiliates
      WHERE  approved = 1
   ORDER BY RAND()
    LIMIT 10",
   array(
   
   )
);
$content = array();
   
   while ($row = $smcFunc['db_fetch_assoc']($rand_aff))
   {     
      $content[] = array(
      'title' => $row['title'],
      'image' => $row['image'],
      'id_affiliates' => $row['id_affiliates'],
      'approved' => $row['approved'],
      );   
   }
      //return $content;
     
      foreach ($content as $row)
     
      echo' <a href="' . $scripturl . '?action=affiliates;sa=out;idaff=', $row['id_affiliates'],'"><img src="'.$row['image'].'" width="88" height="31" alt="'.$row['title'].'"></a>';
   
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Chit-Chat ChatterBox Boss

Now it isn't scrolling or anything they just sit there in a display. (But they do change random display order on refresh)

Currently my working (non random) SP Block is this.
global $smcFunc, $context, $settings, $modSettings, $txt, $scripturl;

$result = $smcFunc['db_query']('', '
   SELECT a.id_affiliates, a.image, a.description
   FROM {db_prefix}affiliates AS a
   WHERE  approved = 1
   ORDER BY a.id_affiliates DESC'
   );

$affiliates = array();
while ($row = $smcFunc['db_fetch_assoc']($result))
{
   $affiliates[] = array(
      'id' => $row['id_affiliates'],
      'image' => $row['image'],
      'description' => $row['description'],
   );
}
$smcFunc['db_free_result']($result);

   echo '   
<marquee direction="', empty($modSettings['scrolldirection']) ? 'left' : 'right', '" onmouseover="scrollAmount=', $modSettings['How_Fast_To_Scrollmo'],'" onmouseout="scrollAmount=', $modSettings['How_Fast_To_Scroll'],'">';

   foreach ($affiliates as $item)
      echo '
      <a href="', $scripturl, '?action=affiliates;sa=out;idaff=', $item['id'],'" target="_blank">
   <img src="', $item['image'],'"  onload="ImageResizer.createOn(this);"  title="', $item['description'],'" alt="', $item['description'],'" /></a>';

   echo '
</marquee>';
Chit-Chat ChatterBox

Our site is open to everyone. It is a resource for anyone and everyone to talk about anything and everything you could possibly think of. It's a great place to come and talk, ask questions, or just simply hang out. We offer many great features. All we ask is that you follow by the site rules. Hope to see you around!
www.chitchatchatterbox.com
Remember in the "Referral" box to put "Caleb" while registering.

SA™

try this

function random_affiliate_block($limit)
{
   global $scripturl, $smcFunc;
   
   $rand_aff = $smcFunc['db_query']('', "
      SELECT title, approved, id_affiliates, image
      FROM {db_prefix}affiliates
      WHERE  approved = 1
   ORDER BY RAND()
    LIMIT $limit",
   array(
   
   )
);
$content = array();
   
   while ($row = $smcFunc['db_fetch_assoc']($rand_aff))
   {     
      $content[] = array(
      'title' => $row['title'],
      'image' => $row['image'],
      'id_affiliates' => $row['id_affiliates'],
      'approved' => $row['approved'],
      );   
   }
      //return $content;
     
      foreach ($content as $row)
     
      echo' <a href="' . $scripturl . '?action=affiliates;sa=out;idaff=', $row['id_affiliates'],'"><img src="'.$row['image'].'" width="88" height="31" alt="'.$row['title'].'"></a>';
   
}

echo '<marquee direction="', empty($modSettings['scrolldirection']) ? 'left' : 'right', '" onmouseover="scrollAmount=', $modSettings['How_Fast_To_Scrollmo'],'" onmouseout="scrollAmount=', $modSettings['How_Fast_To_Scroll'],'">';

random_affiliate_block(10);

echo '</marquee>';


http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Chit-Chat ChatterBox Boss

#327
Now it lists it in the line as if it was going to scroll just ins't scrolling

nevermind it took a little while to load its scrolling .... just the wrong way and wrong speed ... its not picking up my set stuff in the setting ... i will try to play with the code on that end thanks!

Chit-Chat ChatterBox

Our site is open to everyone. It is a resource for anyone and everyone to talk about anything and everything you could possibly think of. It's a great place to come and talk, ask questions, or just simply hang out. We offer many great features. All we ask is that you follow by the site rules. Hope to see you around!
www.chitchatchatterbox.com
Remember in the "Referral" box to put "Caleb" while registering.

Chit-Chat ChatterBox Boss

I cant seem to adjust it to pick up the affiliates settings for direction and speed. also I am now getting this error

8: Undefined variable: modSettings
Apply Filter: Only show the errors from this file
File: /public_html/Test_Site/Sources/SPortal2.php(3147) : eval()'d code
Line: 34
Chit-Chat ChatterBox

Our site is open to everyone. It is a resource for anyone and everyone to talk about anything and everything you could possibly think of. It's a great place to come and talk, ask questions, or just simply hang out. We offer many great features. All we ask is that you follow by the site rules. Hope to see you around!
www.chitchatchatterbox.com
Remember in the "Referral" box to put "Caleb" while registering.

SA™

replace

global $scripturl, $smcFunc;


with

global $scripturl, $modSettings,  $smcFunc;
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Chit-Chat ChatterBox Boss

Still pushing the same error =/
Chit-Chat ChatterBox

Our site is open to everyone. It is a resource for anyone and everyone to talk about anything and everything you could possibly think of. It's a great place to come and talk, ask questions, or just simply hang out. We offer many great features. All we ask is that you follow by the site rules. Hope to see you around!
www.chitchatchatterbox.com
Remember in the "Referral" box to put "Caleb" while registering.

Chit-Chat ChatterBox Boss

I appeared to have fixed it  :D I don't know if its correct or not but I got it to work.


global $scripturl, $modSettings, $smcFunc;
function random_affiliate_block($limit)
{
   global $scripturl, $modSettings, $smcFunc;
   
   $rand_aff = $smcFunc['db_query']('', "
      SELECT title, approved, id_affiliates, image
      FROM {db_prefix}affiliates
      WHERE  approved = 1
   ORDER BY RAND()
    LIMIT $limit",
   array(
   
   )
);
$content = array();
   
   while ($row = $smcFunc['db_fetch_assoc']($rand_aff))
   {     
      $content[] = array(
      'title' => $row['title'],
      'image' => $row['image'],
      'id_affiliates' => $row['id_affiliates'],
      'approved' => $row['approved'],
      );   
   }
      //return $content;
     
      foreach ($content as $row)
     
      echo' <a href="' . $scripturl . '?action=affiliates;sa=out;idaff=', $row['id_affiliates'],'"><img src="'.$row['image'].'" onload="ImageResizer.createOn(this);" alt="'.$row['title'].'"></a>';
   
}

echo '<marquee direction="', empty($modSettings['scrolldirection']) ? 'left' : 'right', '" onmouseover="scrollAmount=', $modSettings['How_Fast_To_Scrollmo'],'" onmouseout="scrollAmount=', $modSettings['How_Fast_To_Scroll'],'">';

random_affiliate_block(7);

echo '</marquee>';


When I changed the image size part to this
onload="ImageResizer.createOn(this);"

And changed

function random_affiliate_block($limit)
{
   global $scripturl, $modSettings, $smcFunc;

To this
global $scripturl, $modSettings, $smcFunc;
function random_affiliate_block($limit)
{
   global $scripturl, $modSettings, $smcFunc;

It seemed to work. I added the same global string to the outside of the function for the lines that are being called below the function closing. That is where the errors were coming from because there was no global string for them.

Let me know if I did something wrong but now since I edited it, it is reading the scroll direct and image size from the affiliates settings in the admin section and is not pushing anymore errors.
Chit-Chat ChatterBox

Our site is open to everyone. It is a resource for anyone and everyone to talk about anything and everything you could possibly think of. It's a great place to come and talk, ask questions, or just simply hang out. We offer many great features. All we ask is that you follow by the site rules. Hope to see you around!
www.chitchatchatterbox.com
Remember in the "Referral" box to put "Caleb" while registering.

SA™

that looks ok so is it working now ?
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Chit-Chat ChatterBox Boss

Yup with my edits combined with yours that I showed in my post before it is working just like the main display on the forum works! Thanks!
Chit-Chat ChatterBox

Our site is open to everyone. It is a resource for anyone and everyone to talk about anything and everything you could possibly think of. It's a great place to come and talk, ask questions, or just simply hang out. We offer many great features. All we ask is that you follow by the site rules. Hope to see you around!
www.chitchatchatterbox.com
Remember in the "Referral" box to put "Caleb" while registering.

TheListener

Installed the mod and received this error

Unknown column 'id_affiliates' in 'field list'
File: /home/visionar/public_html/Sources/Affiliates db.php
Line: 25

SA™

i guess you had the other affiliates mod install in that caser you will need to drop all the tables belonging to the other affiliates mod then reinstal
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

n00dle

Which version am I supposed to use if I have 1.1.9 installed?  I tried both.  The 2.0 doesn't let me apply it when I click apply, nothing happens it just reloads the page and shows the apply link still there.  The other one doesn't give me an option to apply it just says list files and delete.

SA™

http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

asifnur

yo after i installed the mod i tried tryn myslef
i regustered a test user just to test
and i send affilate request then i logged in my email bit  id ont see any request why???

SA™

idk is it will send to the saem addresse that you set smf up with
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Advertisement: