News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

images only show if member id's post count is high enough

Started by Jade Elizabeth, December 30, 2007, 03:49:17 AM

Previous topic - Next topic

Jade Elizabeth

Okay, i have these little images up top of my forums

the top is what guests see, the bottom is what members see.

there are two blocks of code that accomplish this

if ($context['user']['is_logged'])
    echo '<table width="100%" border="0">
  <tr>
    <td>Rocket Radio</td>
    <td width="40%"><a href="http://retro-radio.net:8974/listen.pls" title="Rocket Radio live from radio-forums.net"><img id="r_Rocket" src="Rocket_offair.png"/></a></td>
  </tr>
  <tr>
    <td>Freight Radio</td>
    <td width="40%"><a href="http://retro-radio.net:8952/listen.pls" title="Freight Radio live from radio-forums.net"><img id="r_Freight" src="Freight_offair.png"/></a></td>
  </tr>
  <tr>
    <td>Phoenix Radio</td>
    <td width="40%"><a href="http://retro-radio.net:8966/listen.pls" title="Phoenix Radio live from radio-forums.net"><img src="Phoenix_offair.png" id="r_Phoenix"/></a></td>
  </tr>
  <tr>
    <td>Radio Madness</td>
    <td width="40%"><a href="http://retro-radio.net:8954/listen.pls" title="Radio Madness live from radio-forums.net"><img id="r_Madness" src="Madness_offair.png"/></a></td>
  </tr>
  <tr>
    <td>Radio Hot</td>
    <td width="40%"><a href="http://radio-forums.net:8978/listen.pls" title="Radio Hot live from radio-forums.net"><img id="r_Hot" src="Hot_offair.png"/></a></td>
  </tr>
  <td colspan="4"><font size=1><center>The above stations are hosted by <a href="http://radio-forums.net/">www.radio-forums.net</a></center></font></td>
</table>';



and

else
    echo '<table width="100%" border="0">
  <tr>
    <td colspan="2"><b>Welcome to the AC. Why not try the <a href="http://www.jades-world.com/forums/index.php?topic=114.0">trial account</a>?</b></td>
    <td width="149">Radio Madness</td>
    <td width="223"><a href="http://retro-radio.net:8954/listen.pls" title="Radio Madness live from radio-forums.net"><img id="r_Madness" src="Madness_offair.png"/></a></td>
  </tr>
  <tr>
    <td width="132">Rocket Radio</td>
    <td width="221"><a href="http://retro-radio.net:8974/listen.pls" title="Rocket Radio live from radio-forums.net"><img id="r_Rocket" src="Rocket_offair.png"/></a></td>
    <td>Radio Hot</td>
    <td><a href="http://radio-forums.net:8978/listen.pls" title="Radio Hot live from radio-forums.net"><img id="r_Hot" src="Hot_offair.png"/></a></td>
  </tr>
  <tr>
    <td>Freight Radio</td>
    <td><a href="http://retro-radio.net:8952/listen.pls" title="Freight Radio live from radio-forums.net"><img id="r_Freight" src="Freight_offair.png"/></a></td>
    <td>Phoenix Radio</td>
    <td><a href="http://retro-radio.net:8966/listen.pls" title="Phoenix Radio live from radio-forums.net"><img src="Phoenix_offair.png" name="r_Freight2" id="r_Phoenix"/></a></td>
  </tr>
  <tr>
    <td colspan="4"><font size=1><center>The above stations are hosted by <a href="http://radio-forums.net/">www.radio-forums.net</a></center></font></td>
  </tr>
</table>';


ignoring the images, which i havent created, those ones are used for testing purposes ONLY. i want to make it so the image and link ONLY show if the user who runs the station had a daily average postcount of .900 or above.
or if you cant do decimals (for what ever reason), one a day would be fine :)

the member id's are as follows:
rocket radio-54
freight radio-8
radio madness-32
radio hot-10
radio phoenix-57

i wish for the image to be replaced with an image that says something like "not enough posts" (obviously i will make this image) and removes the hyperlink. i dont want the DJ's abusing the privileges i give them, and i wish to make them earn their button, and maintain it. :)

can anyone help me with this please?
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Bulakbol

Let's plan the plan. :P

if user is guest,
- display the "Welcome..."


if the dj met the required average # of posts
- display radio name in color
- display a clear image
- link

otherwise
- display radio name in gray
- display a blurry image or "not enough posts" text
- no link


Is this the way you want it Alundra?

This mod should query members table and I am not good at queries.
A helpful hand can do the queries and someone can do the coding.
I'll do the talking. lol

Any volunteers?
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Jade Elizabeth

Quote from: JohnyB on December 30, 2007, 12:04:15 PM
Let's plan the plan. :P

if user is guest,
- display the "Welcome..."


if the dj met the required average # of posts
- display radio name in color
- display a clear image
- link

otherwise
- display radio name in gray
- display a blurry image or "not enough posts" text
- no link


Is this the way you want it Alundra?

This mod should query members table and I am not good at queries.
A helpful hand can do the queries and someone can do the coding.
I'll do the talking. lol

Any volunteers?

well when their offline the image will be greyed out. so i just want it replaced.

basically the .js that it comes with displays "off air" by default (each station has their own off air button). when message is sent to my site that a DJ is on air (takes about a minute), the image of the station switches to "on air" (each station has its own on air image). i want it so that if the dj doesnt have enough posts (make it 1 per day instead of .900) their image will be replaced (regardless of on/off air state) with an image that says they dont have enough posts, that isnt hyperlinked.
that way they have to earn and maintain their buttons :)
if there needs to be a cron job or something then i can do that :)
i can run queries too :)

you can see the buttons live on the testing theme
www.jades-world.com/forums/index.php?theme=5
login as trial, with the pass trial to see the members view.
the code for guest/members is allready there, i dont think you will really need to change it.
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Bulakbol

awww thank you. That clears the air. Those who understand javascript can help maybe. Sorry, Javascript is a martian language to me.  :P
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Jade Elizabeth

Quote from: JohnyB on December 30, 2007, 12:57:08 PM
awww thank you. That clears the air. Those who understand javascript can help maybe. Sorry, Javascript is a martian language to me.  :P

no i dont really want the javascript touched...we JUST got it working. id rather php handle this lol
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Bulakbol

We can try then. Maybe like this?

if ($context['user']['is_logged'])
    echo '<table width="100%" border="0">
  <tr>';
   check_his_posts(id#); // function to query table
   if (ok)
       echo '
    <td>Rocket Radio</td>
    <td width="40%"><a href="http://retro-radio.net:8974/listen.pls" title="Rocket Radio live from radio-forums.net"><img id="r_Rocket" src="Rocket_offair.png"/></a></td>';
    else
         echo 'greyed-out texts etc';
    echo '
  </tr>...

Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Jade Elizabeth

yes and no...

i want the text ALWAYS displayed, and the table/cell/row what ever ALWAYS displayed. i want the IMAGE and LINK (contents of the cell) to change if his postcount isnt high enough ;)
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Rudolf

There's no need for querying the database.
In Load.php
Code (Find) Select
'posts' => empty($user_settings['posts']) ? 0 : $user_settings['posts'],

Add after:
Code (Add after) Select
'dateRegistered' => empty($user_settings['dateRegistered']) ? 0 : $user_settings['dateRegistered'],


Code (Find) Select
'email' => &$user_info['email'],
Add after:
'posts_per_day' => round($user_info['posts'] / ((time() - $user_info['dateRegistered']) / (3600 * 24)), 3),


Then you can write in your templates something like this.
Code (php) Select
<?php



if ($context['user']['is_logged'])
   echo
'<table width="100%" border="0">
 <tr>
   <td>Rocket Radio</td>
   <td width="40%">'
, $context['user']['posts_per_day'] > 0.9 ? '<!--****** link and image for when the posts per day is higher then 0.9********--><a href="http://retro-radio.net:8974/listen.pls" title="Rocket Radio live from radio-forums.net"><img id="r_Rocket" src="Rocket_offair.png"/></a>' : '<!--******this when is lower then 0.9********--><a href="http://retro-radio.net:8974/listen.pls" title="Rocket Radio live from radio-forums.net"><img id="r_Rocket" src="Rocket_offair.png"/></a>' , '</td>
 </tr>
 <tr>
   <td>Freight Radio</td>
   <td width="40%">'
, $context['user']['posts_per_day'] > 0.9 ? '<a href="http://retro-radio.net:8952/listen.pls" title="Freight Radio live from radio-forums.net"><img id="r_Freight" src="Freight_offair.png"/></a>' : '<a href="http://retro-radio.net:8952/listen.pls" title="Freight Radio live from radio-forums.net"><img id="r_Freight" src="Freight_offair.png"/></a>' , '</td>
 </tr>
 <tr>
   <td>Phoenix Radio</td>
   <td width="40%">'
, $context['user']['posts_per_day'] > 0.9 ? '<a href="http://retro-radio.net:8966/listen.pls" title="Phoenix Radio live from radio-forums.net"><img src="Phoenix_offair.png" id="r_Phoenix"/></a>' : '<a href="http://retro-radio.net:8966/listen.pls" title="Phoenix Radio live from radio-forums.net"><img src="Phoenix_offair.png" id="r_Phoenix"/></a>','</td>
 </tr>
 <tr>
   <td>Radio Madness</td>
   <td width="40%">'
, $context['user']['posts_per_day'] > 0.9 ? '<a href="http://retro-radio.net:8954/listen.pls" title="Radio Madness live from radio-forums.net"><img id="r_Madness" src="Madness_offair.png"/></a>' : '<a href="http://retro-radio.net:8954/listen.pls" title="Radio Madness live from radio-forums.net"><img id="r_Madness" src="Madness_offair.png"/></a>','</td>
 </tr>
 <tr>
   <td>Radio Hot</td>
   <td width="40%">'
, $context['user']['posts_per_day'] > 0.9 ? '<a href="http://radio-forums.net:8978/listen.pls" title="Radio Hot live from radio-forums.net"><img id="r_Hot" src="Hot_offair.png"/></a>': '<a href="http://radio-forums.net:8978/listen.pls" title="Radio Hot live from radio-forums.net"><img id="r_Hot" src="Hot_offair.png"/></a>','</td>
 </tr>
 <td colspan="4">'
, $context['user']['posts_per_day'] > 0.9 ? '<font size=1><center>The above stations are hosted by <a href="http://radio-forums.net/">www.radio-forums.net</a></center></font>': '<font size=1><center>The above stations are hosted by <a href="http://radio-forums.net/">www.radio-forums.net</a></center></font>' , '</td>
</table>'
;
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

Jade Elizabeth

awesome, and thankyou :D


(he changed
$context['user']['posts_per_day'] > 0.9 ?

to

$context['user']['id'] == 54 && $context['user']['posts_per_day'] > 0.9 ?
by the way to make it work with the users id)


thats awesome :D
now they have to earn their buttons :D

thankyou again!!!!!
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Bulakbol

Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Advertisement: