Jump to content

Showing & Hiding Menu items by login


Recommended Posts

Posted

Alright not exactly sure how to word this but I am trying to use the existing code from the nav.blade.php file for my template. For instance I want to of course show some menu item's to Guest and when they login more appear, just like we do in the original version. I have some of it figured out but I am mot really sure what this code is referring too:

	@foreach($moduleSvc->getFrontendLinks($logged_in=false) as &$link)
        <li class="nav-item">
            <a class="nav-link" href="{{ url($link['url']) }}">
                <i class="{{ $link['icon'] }}"></i>
                <p>{{ $link['title'] }}</p>
            </a>
        </li>
    @endforeach
	

it's the $link stuff I don't really understand? What is it referring too exactly? Any help appreciated! Just trying to learn the basic's :)

Thanks for your help!

 

Posted

Never mind figured out by taking my time, imagine that. Now I gave to go back and clean everything up the way I want it exactly. I would like to know for info reason what some of the code is referring too, like this code?

 

	<a class="nav-link" href="{{ url($link['url']) }}">                
<i class="{{ $link['icon'] }}"></i>                
<p>{{ $link['title'] }}</p> </a>
	

If someone could help me out for the future! Not the class stuff but the $link items, if you would please!

Thanks for your help!

Posted

Thats great, however for future reference you can protect anything on the site with this simple very short script.

For normal members permissions; 

<?php if(Auth::LoggedIn()) { ?>

<!-- your content here etc...... -->

<?php } ?>

For Admin and staff permissions; 

<?php
if(Auth::LoggedIn())
{
    if(PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN))
    { ?>

<!-- your content here etc. -->

<?php } }?>

I use this everywhere I don't want Guests to view any member modules, maps, and/or Pilot Tools, including menus. Hope this helps for the future.

Jim

  • Confused 1
Posted
8 hours ago, Heritage1 said:

Thats great, however for future reference you can protect anything on the site with this simple very short script.

For normal members permissions; 


<?php if(Auth::LoggedIn()) { ?>

<!-- your content here etc...... -->

<?php } ?>

For Admin and staff permissions; 


<?php
if(Auth::LoggedIn())
{
    if(PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN))
    { ?>

<!-- your content here etc. -->

<?php } }?>

I use this everywhere I don't want Guests to view any member modules, maps, and/or Pilot Tools, including menus. Hope this helps for the future.

Jim

Isn't phpVMS version 7 different because it is written with Laravel? Just trying to learn the very basic stuff in the NEW v7!

 

Just wondering!

Posted
16 hours ago, Heritage1 said:

Ahhh, yes your right, didn't know you were running version 7, I'll get back to you on that one, got a few friends around duh boards here, let me see if I can find you and answer.

Jim

I have it working now for the most part and watching video's on Laravel just for general knowledge at this point! I also think I have the basic's about the $link stuff to, I think!

Appreciate the help!

  • Administrators
Posted
On 10/12/2018 at 8:29 PM, in2tech said:

Alright not exactly sure how to word this but I am trying to use the existing code from the nav.blade.php file for my template. For instance I want to of course show some menu item's to Guest and when they login more appear, just like we do in the original version. I have some of it figured out but I am mot really sure what this code is referring too:

 


	@foreach($moduleSvc->getFrontendLinks($logged_in=false) as &$link)
        <li class="nav-item">
            <a class="nav-link" href="{{ url($link['url']) }}">
                <i class="{{ $link['icon'] }}"></i>
                <p>{{ $link['title'] }}</p>
            </a>
        </li>
    @endforeach
	

 

it's the $link stuff I don't really understand? What is it referring too exactly? Any help appreciated! Just trying to learn the basic's :)

Thanks for your help!

 

If you look at the foreach, it says:

@foreach($moduleSvc->getFrontendLinks($logged_in=false) as &$link

So it's grabbing all of the frontend links as $link. If the module you create says that's allowed for guest users, that will get the link as defined for that module. I need to write some extra documentation around this feature:

http://docs.phpvms.net/developers/add-ons-and-module

Posted

If I would have looked closer I would have seen that one states logged_in=false and one says logged_in=true, and now that explains what links are show if logged in or not logged in, I think! Ot at least that is the way it is working for me the way I have it set up. Which I basically just copied it from the original nav_blade.php :)  Finally got the basic Laravel install on my Mac working but no Homestead or Valet. Still learning and just trying to understand the code and maybe one day be able to create at least a simple module, just maybe! Mainly focusing on making a new theme, well converting one to v7 I should say, and although it looks fairly decent NONE of the phpVMS code actually works in it, Live Map, Registration, Filing New PIREP, but it kind of looks nice, but that's all! Converting templates the OLD school way like phpVMS 2 or 5 or whatever they are called now, by just copying Laravel code from the original default template or making a copy of it and then adding my template conversion! At least I am trying :) And it looks pretty good, just nothing works :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...