DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • October 22, 2018, 06:52:37 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Tabs on MOTD Header To Turn Red When New MOTD  (Read 1436 times)
0 Members and 1 Guest are viewing this topic.
Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1053



View Profile WWW
« on: May 19, 2018, 11:53:12 PM »

I want each of the tabs other than the MOTD one, which I have called Kinks, to turn red when there is a new one. I tried to get help and it just didnt work and the person swears it will work this way and its not. I have tested it multiple times. I'll put the code below and someone can tell me where we messed up. Thanks!

Code:
$a=translate_inline("Kinks");
$b=translate_inline("Contests & Events");
$c=translate_inline("Polls");

if ($session['needtoviewcontest'] == 1)
$highlight_contests = "<a href='motd.php?op=contest' style='color:red'>$b</a>";
else
$highlight_contests = "<a href='motd.php?op=contest'>`r$b</a>";

if ($session['user']['needtoviewpolls'] == 1)
$highlight_polls = "<a href='motd.php?op=poll' style='color:red'>$c</a>";
else
$highlight_polls = "<a href='motd.php?op=poll'>`L$c</a>";

if ($session['user']['needtoviewchangelog'] == 1)
$changelog = "<a href='motd.php?op=changelog' style='color:red'>Server Updates/Enhancements</a>";
else
$changelog = "<a href='motd.php?op=changelog'>`4Server Updates/Enhancements</a>";

output("<center><big><a href='motd.php'>`5$a</a> | $highlight_contests | $highlight_polls | $changelog</big></center><br>",true);
Logged

Aeolus
Mod God
*****
Offline Offline

Posts: 1896


You're welcome.


View Profile WWW
« Reply #1 on: May 20, 2018, 01:17:19 AM »

You're using to $session['needtoviewcontest'], $session['user']['needtoviewpolls'] and $session['user']['needtoviewchangelog'] check if you need to highlight the links.

Do these variables exist? Do needtoviewpolls and needtoviewchangelog exist in the accounts table, and therefore the $session['user'] array? Are you setting $session['needtoviewcontest']? How?
Logged

Sunday
Codemeister
****
Offline Offline

Posts: 399


So meme'd up.


View Profile
« Reply #2 on: May 20, 2018, 08:07:03 AM »

I want each of the tabs other than the MOTD one, which I have called Kinks, to turn red when there is a new one. I tried to get help and it just didnt work and the person swears it will work this way and its not. I have tested it multiple times. I'll put the code below and someone can tell me where we messed up. Thanks!

Code:
$a=translate_inline("Kinks");
$b=translate_inline("Contests & Events");
$c=translate_inline("Polls");

if ($session['needtoviewcontest'] == 1)
$highlight_contests = "<a href='motd.php?op=contest' style='color:red'>$b</a>";
else
$highlight_contests = "<a href='motd.php?op=contest'>`r$b</a>";

if ($session['user']['needtoviewpolls'] == 1)
$highlight_polls = "<a href='motd.php?op=poll' style='color:red'>$c</a>";
else
$highlight_polls = "<a href='motd.php?op=poll'>`L$c</a>";

if ($session['user']['needtoviewchangelog'] == 1)
$changelog = "<a href='motd.php?op=changelog' style='color:red'>Server Updates/Enhancements</a>";
else
$changelog = "<a href='motd.php?op=changelog'>`4Server Updates/Enhancements</a>";

output("<center><big><a href='motd.php'>`5$a</a> | $highlight_contests | $highlight_polls | $changelog</big></center><br>",true);

You don't have an opening tag. PHP requires <?php at the start of each page. As Aeolus has said, there is probably an accounts table issue. There seems to be some confusion here as to what you are trying to do, between your developers. The status of the polls and changelogs is stored on the account, but the contest status is stored in the session. This would mean that the contest is probably changing with each login. There are no setters here for any of the contests, polls, or changelogs here - so we cannot help you properly. You need to include the other parts of this code, because this is clearly not where the issue lies, except for maybe the $session['needtoviewcontest'] not being a saved variable.

Also, it seems as if the changelog will be perpetually red, since the LotGD color code for red is `4 and you have style='color:red' in the if statement.
Logged

Slowly progressing fork with PHP 7 support: https://github.com/stephenKise/Legend-of-the-Green-Dragon
Cheap VPS Hosting (10$ credit!): https://m.do.co/c/acde75b086c5

A new server in the making...
Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1053



View Profile WWW
« Reply #3 on: May 20, 2018, 12:56:27 PM »

To better answer all questions I have attached both the main folder motd file and the lib folder one. Please point me to where we went wrong.
Logged

Aeolus
Mod God
*****
Offline Offline

Posts: 1896


You're welcome.


View Profile WWW
« Reply #4 on: May 21, 2018, 02:50:04 AM »

To better answer all questions I have attached both the main folder motd file and the lib folder one. Please point me to where we went wrong.

We've already told you. TL;DR: You're not setting the session variables, differing in that some of which are session variables and some of which are account variables (why they are session/account variables in the first place, I don't know), and you're setting the changelog to `4 (red) if there's no changes to view.
« Last Edit: May 21, 2018, 07:13:56 AM by Aeolus » Logged

Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1053



View Profile WWW
« Reply #5 on: May 22, 2018, 04:35:23 AM »

So how would I set the variables to fix this? I tried other things to fix it like copying how the pageparts did it for the main MoTD link on the page header and changing the link appropriately and that didnt work. I also tried adding global $session and that didnt work.
Logged

Aeolus
Mod God
*****
Offline Offline

Posts: 1896


You're welcome.


View Profile WWW
« Reply #6 on: May 22, 2018, 07:31:51 AM »

You need to understand what you're doing. You can't code by trial and error, and copying. That's how you break things and end up with terrible code.

You need a pref or an accounts parameter that gets set to false for everyone whenever a new item is posted. If it's false for you, it turns red. You can then set it to true when it's viewed.

Do $session['needtoviewcontest'], $session['user']['needtoviewpolls'] and $session['user']['needtoviewchangelog'] exist? Do the variables themselves exist, as well as in the accounts table (for the latter two)?
Logged

Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1053



View Profile WWW
« Reply #7 on: May 22, 2018, 01:17:01 PM »

If you saw the code you would see in each case that this code is there.

$session['user']['needtoviewcontest']=false;

The only one its not there for is the changelog. The changelog case has this.

$session['user']['seenupdates'] = TRUE;

As for the latter, the only user account thing in changelog is for pulling the poster's name just like in the lib file all the user things are for who the poster is. With the polls this is the only user account thing.

$session['user']['lastmotd']=$row['motddate'];
« Last Edit: May 22, 2018, 01:19:29 PM by Megan|SaraBeth » Logged

Aeolus
Mod God
*****
Offline Offline

Posts: 1896


You're welcome.


View Profile WWW
« Reply #8 on: May 22, 2018, 05:50:20 PM »

Wow, I'm confused... You have both $session['needtoviewcontest'] and $session['user']['needtoviewcontest']? And opposing "need to view" and "have seen" variables? What happened to consistency...

When are those updated to the OTHER case? When is needtoviewcontest set to true, and seenupdates set to false? If those parameters aren't in the accounts table, then how do they exist in $session['user']?
Logged

Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1053



View Profile WWW
« Reply #9 on: May 24, 2018, 08:15:57 PM »

Contests and polls are set to true with this in their respective spots in the lib/motd.php

db_query("UDPATE accounts SET needtoviewcontest=1");

Seenupdates is not set to false and I wouldnt know where to set it.  Im thinking the first $session without ['user'] needs it. Im lost really as how to fix this.
Logged

Sunday
Codemeister
****
Offline Offline

Posts: 399


So meme'd up.


View Profile
« Reply #10 on: May 26, 2018, 11:08:14 AM »

Seenupdates is not set to false and I wouldnt know where to set it.  Im thinking the first $session without ['user'] needs it. Im lost really as how to fix this.

The status of the polls and changelogs is stored on the account, but the contest status is stored in the session. [...] maybe the $session['needtoviewcontest'] not being a saved variable.
Logged

Slowly progressing fork with PHP 7 support: https://github.com/stephenKise/Legend-of-the-Green-Dragon
Cheap VPS Hosting (10$ credit!): https://m.do.co/c/acde75b086c5

A new server in the making...
Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1053



View Profile WWW
« Reply #11 on: May 26, 2018, 03:40:16 PM »

After looking at the code and taking into account what y'all said, We have found that my db prefix was missing and there was a spelling error. It has been fixed now. Thank you for the guidance.
« Last Edit: June 04, 2018, 11:36:36 AM by Megan|SaraBeth » Logged

Aeolus
Mod God
*****
Offline Offline

Posts: 1896


You're welcome.


View Profile WWW
« Reply #12 on: May 26, 2018, 05:05:41 PM »

You're welcome. Still doesn't explain why you're using $session['needtoviewcontest'] instead of $session['user']['needtoviewcontest'].
Logged

Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1053



View Profile WWW
« Reply #13 on: May 26, 2018, 07:17:58 PM »

Its been changed to that as well.
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
45 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search