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
You have the right idea. Currently, that is the easiest way IMO.
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??
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.
Cheeers
I'll have a play.
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
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>';
}
$$context should be $context
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
Can you post the code you are using?
Yes, there IS no '<' on line 1 of the code I posted.
Note that you DO NOT start a php block/article with "<? php" or end it with "?>". If you have those, take them out and use JUST the code provided.
I am literally using the script that you included above.
<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 ' Newspapers are posted quaterly for members';
}
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>';
}
I'm not really smart enough to change things that people give me.
Dog
No. That's just the script that YOU originally posted. ;)
Mine is included in http://www.tinyportal.net/index.php?topic=20576.msg168996#msg168996
The first line of it is
echo '
Ok
My Bad. I still get an error.
[EDIT] - No I don't. I hadn't hit save. Thanks JAC.
Cheers
Dog
Can we mark this topic Solved Dog?
YEs Thanks Z. Chalk it up to gross stupidity and failure to follow instructions completely on my behalf!
Thanks for the support all!
Dog