Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8043 Posts in 1856 Topics- by 2099 Members - Latest Member: roi
Pages: [1]   Go Down
Print
Author Topic: hidden events  (Read 792 times)
0 Members and 1 Guest are viewing this topic.
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« on: March 02, 2007, 04:14:00 AM »

so i know i have to be close...

<% next unless ($EVENT->{'event_id'}->{'security'} eq "Hidden" && $User->{username} ne "Administrator"); %>

im putting this in the <%FOREACH EVENT%> loop to prevent events from displaying if the custom event field 'security' is set to hidden.

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #1 on: March 02, 2007, 11:48:00 AM »

** if the custom event field 'security' is set to hidden. **

Set to "hidden" or "Hidden"?? There is a difference.

Also, what is "event_id" in the expression suppose to be? I would assume it should be some type of actual value (a number for example) but without seeing in what context it is being used, it is impossible to say.

Hint: Try printing out that variable ( $EVENT->{'event_id'}->{'security'} ) to see what value is being used on your conditional statement.

Dan O.

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #2 on: March 02, 2007, 02:00:00 PM »

i thought event_id was how i specified the name of the field that i want to compare to.

The field i have created is called 'Security' with an event_id of 'security'.  It is a selectbox with 3 options 'Public', 'Private' and 'Hidden'

so with the statement...
<%-- next unless ($EVENT->{'event_id'}->{'security'} eq "Hidden" && $User->{username} ne "Administrator"); --%>

i wanted to continue the FOREACH EVENT, unless the event_id for the field 'Security' was 'Hidden AND the Administrator isnt logged in.  Hope that helps clarify

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #3 on: March 02, 2007, 09:35:00 PM »

** The field i have created is called 'Security' with an event_id of 'security'. **

The "event_id" is the number (ie. "index") of an event record (the whole thing) in the schedule.txt file. It is only used to link a schedule to a particular event.

** i wanted to continue the FOREACH EVENT, unless... **

Have a look in the previous forum message "First attempt at customization (hiding events unless...)" to see if you can get an idea of how event record details are accessed.

Dan O.

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #4 on: March 02, 2007, 10:14:00 PM »

yeah i was actually referencing that thread before, but i found that im matching to a string i need to use eq, ne, etc instead of ==

i guess the thing throwing me off is when i created the field, the event_id field wasnt a number.  it was automatically populated from the field display name..

so now i have....
<% next unless $EVENT->{'details'}->{'security'} eq "Hidden" && $User->{username} ne "Administrator"; %>

but it isnt showing any of events now.  even if im logged in

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #5 on: March 03, 2007, 12:43:00 AM »

** it isn't showing any of events now **

What will $EVENT->{'details'}->{'security'} print out as on the template?? That should at least show you if that might still be part of the problem.

You could also try only using one half of the conditional expression and then the other, to try to see which (if any) is the problem.

Also, all the conditionals should be enclosed inside (...)

Dan O.

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #6 on: March 03, 2007, 03:54:00 PM »

how do i print it out?

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #7 on: March 03, 2007, 04:55:00 PM »

** how do i print it out? **

The same way you're print any other variable out: <%= ... %>

See "Tag Syntax" in the Documentation.

Dan O.

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #8 on: March 03, 2007, 06:27:00 PM »

got it!

<% next if ($EVENT->{details}->{'security'} eq "hidden" && $User->{username} ne "Administrator"); %>

i also thought that next if statement, when it goes to the 'next', the 'next' isnt the next line, its the next statement.  so basically next doesnt continue the code, it skips code...

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #9 on: March 03, 2007, 09:04:00 PM »

** got it! **

Glad to hear it.

** <% next if ($EVENT->{details}->{'security'} eq "hidden" ... **

So it was printing out "hidden" and not "Hidden" (which is what your original conditional statement was checking for)? I mentioned that possibility in my very first reply to you.

** thought that next if statement, when it goes to the 'next', the 'next' isnt the next line, its the next statement. **

I'm not sure what you're trying to say there. The "next" statement means start the next iteration of the loop... from the beginning (usually with a new variable to work on).

** it skips code... **

Right. It skips all other statements in the loop and starts again from the top of the loop with the next item being looped through.

You might want to check out "Perl Tutorial: Start" although I don't think they touch upon the 'next' statement. That is covered here: Control Structures - for, foreach, while, if. They might help you to better understand what's going on in the Perl code?

JMO

Dan O.

------------------

Logged
Pages: [1]   Go Up
Print
Jump to: