Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Hide Elements with PHP..?

Featured Replies

I need to display a nav menu on every page except the home page [don't ask me why - it's not my design].

 

Question is, can I hide an element with PHP as you would with js/jq..? As the url is the obvious variable I figure I may as well do it server-side if possible...

 

Thanks..!

  • Author

Simple if statement.

 

I was hoping so. Could you give us an example in context as far as the hide/show side of things go with php..? I get the rest, but I'm completely new to php, and it's the hiding/showing side of things I'm not quite sure about...

Maybe this method will work.

 

Give Home $hide = 1

 


if ($hide != 1){
Show your nav
}

Edited by marcelc

  • Author

So are there actually show/hide functions in php, or will I have to make one [i haven't come across any while looking]..?

 

Forgive me, I was told I should have no problems with php as I'm comfortable with javascript, but it feels like that's just making it worse in these early stages...

I'm new in javascript and haven't play a lot with it and still in learning process but i can say that Javascript and PHP are completely different language.

 

So far, I notice that Javascript and PHP have similar structure and logic, and maybe this is why you thought you will have no problem with PHP because you're comfortable with Javascript.

 

The main difference is the purpose of each language. While Javascript can do some data manipulations, mostly Javascript is used for front end purpose, therefore, manipulating classes and objects are possible with provided methods and properties. However, PHP is more on handling datas, input and output. Front end stuff is possible with PHP, but it is not that advance and might required some twisted logic.

 

To answer your question, there is no syntax (there might be one, haven't found one though) specifically to show/hide object, but it's possible by creating condition like what I did before. You can also define some css class and change it with PHP if your nav bar met a specific condition.

 

CMIIW though, because i'm a newbie myself :p

 

Hope this helps.

Edited by marcelc

  • Author

Thank you..! I thought I was being a complete moron not picking this up almost instantly - especially, as you say, considering the similar structure...

 

I was wondering about targeting CSS as well - that's good to know..! Think I will give that a look.

 

Thanks again...

  • Author

Yep, I went with that very solution in the end. Never would have thought it could be as simple as putting html between php tags..!

 

Thanks..!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.