TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,022
  • Total Topics: 21,332
  • Online today: 725
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 368
  • Total: 368

Guest Exclusion from Articles

Started by Maddog452, December 08, 2007, 10:30:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Maddog452

I have a number of articles on my Site that contain some information that anyone who visits the site needs and some more info that only members should have access to.  For example, on our committee page, they want to explain the structure but without disclosing the names and contact details of the committee members to guests.

I was planning to take the current article and make it a PHP article and then have a block of code like:

global $$context;
if ($context['user']['is_guest']) {
   Text here; }
else {
   Different Text HEre.


Firstly will this work?, Is there an easier way? And can someone help me with the code.

Cheers

DM

IchBin

You have the right idea. Currently, that is the easiest way IMO.

Maddog452

I was able to pluck the code below off another snippet I was given but i have seen that if your syntax is poor then you can have issues. A simple "," or ":" in the wrong place means that it doesn't work.

global $$context;
if ($context['user']['is_guest']) {
   Block of Text here; }
else {
   Different Block of Text Here}


Is the code above correct??

IchBin

Why don't you test it and see? You'll find out quicker than if you had waited for me. lol

You'll need to echo your code in between the brackets.

Maddog452


Maddog452

#5
I have (as usual) confused myself increadibly. I have changed the way I want to do this page such that it is:

General Blurb, Blah Blah BLah.
global $$context;
if ($context['user']['is_guest']) {
      Sorry No newsletters; }
else {
   Lists of Letters}
echo

To confuse matters greatly, I ticked the make PHP article box and now I am lost!!!

This is the page I have:

<p align="center"><font size="3"><strong>Association Newsletters<br />
</strong></font></p>
<p align="left"><font size="2">Every Three months, the committee will release a newsletter to all members via email.  Once released, the newsletters are available to all members on this site.<br />
<br />
If you have an article that you would like included in the Newsletter, please send an email to the editor of the newsletter by clicking on this </font><a href="mailto:graeme.andrews@defence.gov.au?subject=Article%20for%20Newsletter"><font size="2">link</font></a><font size="2">.<br />
<br />
<<ME>> global $$context;
if ($context['user']['is_guest']) {
Echo ' Newsletters are available to members here quarterly';
}
else {
Echo ' <<ME>> A list ot the past newsletters is detailed below:<br />
<br />
Volume 1<br />
  <a href="http://theblackhand.asn.au/forum/tp-images/Image/Newsletter_Vol_1_Iss_1_Mar_07.doc">Edition 1 - Mar 07</a><br />
  <a href="http://theblackhand.asn.au/forum/tp-images/Image/Newsletter_Vol_1_Iss_2_Jun_07.doc">Edition 2 - Jun 07</a><br />
  <a href="http://theblackhand.asn.au/forum/tp-images/Image/Newsletter Vol 1 Iss 3 Oct 07.pdf">Edition 3 - Oct 07</a></font><font size="2"><br />
Volume 2<br />
  Edition 1 - Feb 08<br />
  Edition 2 - May 08<br />
  Edition 3 - Aug 08<br />
  Edition 4 - Nov 08 </font></p> <<ME>>';
}<<ME>>


I added the bits marked between the <<ME>> after the page "changed". I don't understand enough about PHP. Happy for you to push me to a good tutorial

[EDIT] - i get the following error:
QuoteParse error: syntax error, unexpected '<' in /home/the15537/public_html/forum/Sources/Load.php(1735) : eval()'d code(209) : eval()'d code on line 1

Cheers
Dog

jacortina

Using a PHP article should be fine. But that means that everything read in will be 'parsed' as PHP (that's wht the "eval" function does).

But, your first line ISN'T PHP. So, first thing, you need to wrap that top part in an 'echo' statement (PHP is a Hypertext Preprocessor; what it outputs via 'echo' is sent to the user's browser and is usually composed of the HTML you want the browser to 'see').

echo '
<p align="center"><font size="3"><strong>Association Newsletters<br />
</strong></font></p>
<p align="left"><font size="2">Every Three months, the committee will release a newsletter to all members via email.  Once released, the newsletters are available to all members on this site.<br />
<br />
If you have an article that you would like included in the Newsletter, please send an email to the editor of the newsletter by clicking on this </font><a href="mailto:graeme.andrews@defence.gov.au?subject=Article%20for%20Newsletter"><font size="2">link</font></a><font size="2">.<br />
<br />
';

global $$context;
if ($context['user']['is_guest']) {
echo ' Newsletters are available to members here quarterly';
}
else {
echo ' A list ot the past newsletters is detailed below:<br />
<br />
Volume 1<br />
  <a href="http://theblackhand.asn.au/forum/tp-images/Image/Newsletter_Vol_1_Iss_1_Mar_07.doc">Edition 1 - Mar 07</a><br />
  <a href="http://theblackhand.asn.au/forum/tp-images/Image/Newsletter_Vol_1_Iss_2_Jun_07.doc">Edition 2 - Jun 07</a><br />
  <a href="http://theblackhand.asn.au/forum/tp-images/Image/Newsletter Vol 1 Iss 3 Oct 07.pdf">Edition 3 - Oct 07</a></font><font size="2"><br />
Volume 2<br />
  Edition 1 - Feb 08<br />
  Edition 2 - May 08<br />
  Edition 3 - Aug 08<br />
  Edition 4 - Nov 08 </font></p>';
}

IchBin


Maddog452

So I was pretty close.

Thanks - You guys rock

[EDIT] I still get the following error.

QuoteParse error: syntax error, unexpected '<' in /home/the15537/public_html/forum/Sources/Load.php(1735) : eval()'d code(209) : eval()'d code on line 1

Bugger - Bugger

Zetan

Can you post the code you are using?

This website is proudly hosted on Crocweb Cloud Website Hosting.