--- title: Conditionally Adding Items weight: 3 --- v1.1+ The `add` method has an equivalent method with an `if` suffix, which takes a condition as it's first argument. The items will only be added to the menu if the condition resolves to true (non-strict). ```php Menu::new() ->add(Link::to('/', 'Home')) ->addIf(!$loggedIn, Link::to('/login', 'Login')) ->addIf(!$loggedIn, Link::to('/register', 'Register')) ->addIf($loggedIn, Link::to('/logout', 'Logout')) ``` ```html ``` ```html ``` This also applies to the convenience methods: ```php Menu::new() ->link('/', 'Home') ->htmlIf(count($notifications), ''); ``` ```html ``` ```html ```