You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 291 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Restricting access to a News article's "bodytext" [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
oaklid
Corporal
Corporal


Joined: May 30, 2003
Posts: 56


PostPosted: Mon Jun 02, 2003 12:02 am Reply with quoteBack to top

On the site I'm putting together, I'd like to restrict the full text of an article to registered users only.

All visitors would to be able to read the "story text" (hometext field) of an article on the home page, and when clicking through to articles from the Topics module, too. But only registered users will be able to read the full article (bodytext field)

I've peeked at modules/News/article.php (and the other scripts under News) and it's just out of my league. I can tweak code, but I want a very big tweak, I think!

Has anyone done this? Is there a hack out there somewhere that I can use?

Thanks for your advice.

--
Kristen
Find all posts by oaklidView user's profileSend private message
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Mon Jun 02, 2003 12:01 pm Reply with quoteBack to top

Actually it's much easier than you think Wink

In modules/News/index.php, find this line
Code:
   if ($fullcount > 0 OR $c_count > 0 OR $articlecomm == 0 OR $acomm == 1) {
and change it to
Code:
   if (is_user($user) AND ($fullcount > 0 OR $c_count > 0 OR $articlecomm == 0 OR $acomm == 1)) {

The same code is in categories.php so you might want to change it there too. Have fun!

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
oaklid
Corporal
Corporal


Joined: May 30, 2003
Posts: 56


PostPosted: Mon Jun 02, 2003 2:19 pm Reply with quoteBack to top

Thank you, Raven. That did the trick.

--
Kristen

_________________
Kristen
http://www.mediatinker.com/
Find all posts by oaklidView user's profileSend private message
oaklid
Corporal
Corporal


Joined: May 30, 2003
Posts: 56


PostPosted: Mon Jun 02, 2003 3:41 pm Reply with quoteBack to top

And an improved trick. This one tells people to log in or register to see more.

Code:

if (is_user($user) AND ($fullcount > 0 OR $c_count > 0 OR $articlecomm\
 == 0 OR $acomm == 1)) {
      $morelink .= "$story_link<b>"._READMORE."</b></a> | ";
} else {
       $morelink .= "<a href=\"modules.php?name=Your_Account\">log in</a> or <a href=\"modules.php?name=Your_Account&op=new_user\">register</a> to read more |";
}


In a perfect world, I'd also have a blank morelink for when there is no more article, but I just haven't gotten the hang of elseif.

_________________
Kristen
http://www.mediatinker.com/
Find all posts by oaklidView user's profileSend private message
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Mon Jun 02, 2003 3:44 pm Reply with quoteBack to top

Code:

if (condition1) { do_stuff2;}
elseif (condition2) { do_stuff2;}
elseif (condition3) { do_stuff3;}
elseif (condition4) { do_stuff4;}
else {do_this;}

Does that help?

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
oaklid
Corporal
Corporal


Joined: May 30, 2003
Posts: 56


PostPosted: Mon Jun 02, 2003 4:51 pm Reply with quoteBack to top

I should have been more specific. I get the concept of elseif, but I couldn't make it work in this context. I guess my problem is that I don't know how to define the condition of "not a logged in user" But I will admit I haven't been trying too hard to figure it out, either.

What I'd want is

if (is_user($user) AND ($fullcount > 0 OR $c_count > 0 OR $articlecomm== 0 OR $acomm == 1)) {
$morelink .= "$story_link<b>"._READMORE."</b></a> | ";
} elseif (NOT LOGGED IN) AND ($fullcount > 0 OR $c_count > 0 OR $articlecomm== 0 OR $acomm == 1)){
$morelink .= "<a href=\"modules.php?name=Your_Account\">log in</a> or <a href=\"modules.php?name=Your_Account&op=new_user\">register</a> to read more |";
} else {
$morelink .="";
}

Which should show "read more" if the user is logged in and there is more article to read; show "log in or register" if the user is not logged in and there is more article to read; and show nothing if there is no more article to read.

_________________
Kristen
http://www.mediatinker.com/
Find all posts by oaklidView user's profileSend private message
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Mon Jun 02, 2003 5:12 pm Reply with quoteBack to top

Try this
Code:
elseif (!is_user($user))

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
oaklid
Corporal
Corporal


Joined: May 30, 2003
Posts: 56


PostPosted: Tue Jun 03, 2003 12:33 am Reply with quoteBack to top

/me bangs head hard...harder...

thank you.

_________________
Kristen
http://www.mediatinker.com/
Find all posts by oaklidView user's profileSend private message
oaklid
Corporal
Corporal


Joined: May 30, 2003
Posts: 56


PostPosted: Tue Jun 03, 2003 1:15 am Reply with quoteBack to top

So for anyone who has been following along and wants to try this at home, the correct code for News/index.php and News/categories.php is:

Code:
if (is_user($user) AND ($fullcount > 0 OR $c_count > 0 OR $articlecomm== 0 OR $acomm == 1)) {
  $morelink .= "$story_link"._READMORE."</a> | ";
} elseif (!is_user($user) AND ($fullcount > 0 OR $c_count > 0 OR $articlecomm== 0 OR $acomm == 1)){
  $morelink .= "<a href=\"modules.php?name=Your_Account\">log in</a> or <a href=\"modules.php?name=Your_Account&op=new_user\">register</a> to read more |";
} else {
  $morelink .="";
}


With all credit going to Raven.

_________________
Kristen
http://www.mediatinker.com/
Find all posts by oaklidView user's profileSend private message
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by TOGETHER TEAM srl ITALY http://www.togetherteam.it - DONDELEO E-COMMERCE http://www.DonDeLeo.com - TUTTISU E-COMMERCE http://www.tuttisu.it
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.180 Seconds - 258 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::