Forum
Members app with list and detail
Hi,
a question regarding mixing the members app with the list and detail setup. I have got both working after a few hiccups, with this code:
<?php
if (perch_member_logged_in()) {
echo '<h3>Hallo '.perch_member_get('first_name').', Sie sind Eingeloggt!</h3>';
}else{
echo '<h3>Hallo!</h3>';
echo '<p>Sie sind nicht eingeloggt.</p>';
}
?>
<?php
if (perch_member_logged_in()) {
?>
<?php
perch_content_create('Adressen', array(
'template' => 'adressverwaltung_detail.html',
'multiple' => true,
'edit-mode' => 'listdetail',
));
if (perch_get('s')) {
// Detail mode
perch_content_custom('Adressen', array(
'template' => 'adressverwaltung_detail.html',
'filter' => 'slug',
'match' => 'eq',
'value' => perch_get('s'),
'count' => 1,
));
} else {
// List mode
perch_content_custom('Adressen', array(
'template' => 'adressverwaltung_list.html',
));
}
?>
<?php
}else{
perch_members_login_form();
}
?>
There seems to be a lot of if/else going on, is this good code and can I rely on this?
thanks
Hi Matthew,
The logic of your code looks sound. It could just be a bit more efficient. You have a lot of unnecessary opening an closing PHP tags. You can remove them all and just have opening at top and closing at the bottom.
You could also deal with your 'if logged in' statements together too.
You should also create the region first. Otherwise it won't initially get created unless the user is logged in. Like this:
Thank you Simon!