I want a module to become proven such as this:

if (the user is logged in){
    \\ module should be this html(1)
}else{
    \\ module should be like this html(2)
}

is possible? must i add sth within the template index.php?

$user = JFactory::getUser();
if ($user->id){
    \\ module should be this html(1)
}else{
    \\ module should be like this html(2)
}