The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Permissions for pages
#1
Hello,
I have set the permissions for my own pages in the dashboard. The side only shall be shown if one has the right to it (Admin)
I hope somebody can say me what I have made wrong.
Best regards,
kampfaffe
  Reply
#2
Hi, I'm not sure I understand what the issue is. What is not working as expected?
  Reply
#3
Ahh. I see what you're saying. You only want a particular element of the page to be shown if you are an admin. That is very similar to the way we do the menus.

Whatever you want to "hide" for non admin users, wrap the entire thing in this statement...

Code:
<?php if (checkMenu(2,$user->data()->id)){
//Your php/html code here
Code:
}  ?>


  Reply
#4
Hello,
thank you for response. That sounds good, but it don`t work for me.

At the moment, this is my script for the menu of the homepage:
<pre>
<pre>
Code:
<nav>
    <div class="wrapper">
      <ul id="menu" class="clearfix">
        <li><a href="/sani">Home</a></li>
        
<li><a href="#">Dienstpläne</a>
          <ul>
            <li class="purple"><a href="/sani/aktuell/kw38.php">Aktuell</a>
            </li>
            <li class="purple"><a href="#">Archiv</a>
              <ul>
                <li><a href="/sani/archiv/2016/september">September</a></li>
                
                <li><a href="/sani/archiv/2016/juli">Juli</a></li>
                <li><a href="#">Juni</a></li>
              </ul>
            </li>

            <li class="purple"><a href="#">Erstellen</a>
              <ul>
                <li><a href="/sani/admin/kw38_erstellen.php">KW38</a></li>
                <li><a href="#">KW39</a></li>
                <li><a href="#">KW40</a></li>
              </ul>
            </li>

          </ul>
        </li>
                <li><a href="/sani/termine.php">Termine</a></li>
                <li><a href="/sani/changelog.php">Changelog</a></li>

      </ul>
    </div>
  </nav>
</pre>

</pre>

Now, i wan't to hide the following:
<pre>
<pre>
Code:
<li class="purple"><a href="#">Erstellen</a>
              <ul>
                <li><a href="/sani/admin/kw38_erstellen.php">KW38</a></li>
                <li><a href="#">KW39</a></li>
                <li><a href="#">KW40</a></li>
              </ul>
            </li>
</pre>



So I did this:

<pre>
Code:
<?php if (checkMenu(2,$user->data()->id)){
            <li class="purple"><a href="#">Erstellen</a>
              <ul>
                <li><a href="/sani/admin/kw38_erstellen.php">KW38</a></li>
                <li><a href="#">KW39</a></li>
                <li><a href="#">KW40</a></li>
              </ul>
            </li>
} ?>
</pre>

</pre>

But now, there is the following Error in the Apache log: PHP Parse error: syntax error, unexpected '<' in /var/www/html/secret/sani/termine.php on line 35.


Thank you for your help!
  Reply
#5
Can you paste these chunks of code over at pastebin.com or hastebin.com and share the links back here so I can read them a little bit better. We're working on a fix for the code in our forums, but right now, I can't read that very well.
  Reply
#6
Hello,
here with Hastebin:

At the moment, this is my script for the menu of the homepage:
http://hastebin.com/qikiwehoba.html

Now, I wan’t to hide the following:
http://hastebin.com/emenokuxog.html

So I did this:
http://hastebin.com/ufucoxojeb.html

But now, there is the following Error in the Apache log: PHP Parse error: syntax error, unexpected '<' in /var/www/html/secret/sani/menu/index.html on line 19
  Reply
#7
When you make that change, you are essentially going from html here:
</li>
to php and then back to html and then back to php and back to html. Each time you need to make sure you close php and reopen it. So, instead of ...

Code:
<?php if (checkMenu(2,$user->data()->id)){
Code:
<li class="purple"><a href="/sani/admin/erstellen.php">Erstellen</a>
Code:
</li>
Code:
} ?>

It should be

Code:
<?php if (checkMenu(2,$user->data()->id)){ ?>
See how I closed php?
Code:
<li class="purple"><a href="/sani/admin/erstellen.php">Erstellen</a>
I went back to standard html
Code:
</li>
Code:
<?php } ?>
Then I opened php put a } and closed it to complete the if statement
Code:
</ul>
Then went back to regular html.

I hope that helps.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)