Smf user Menu Beta Mod

Started by Faevilangel, August 11, 2009, 07:02:08 AM

Previous topic - Next topic

Arantor

That's for editing your own profile.

Surely you're checking if($['context']['is_logged']) for the user being logged in (and thus able to see the menu)?

Antechinus

Yes but depending on the membergroup and the specific permissions set in admin some groups may not be allowed to view profile. That's why index.template uses a different conditional to the one you suggest.

ETA: Also some sites allow guests to view profile. ;)

Faevilangel

would i need to add a zindex to anywhere else or just the menu ? like the avatars ?

i haven't added a conditional to check user is logged in  :o i have just added a conditional that antechinus posted

should i add the user logged in conditional  ?

this is getting complex ahah
I am available for theme work, pm me for info

Arantor

If you're going down that road, you could also consider making Send PM available based on user privileges too.

Antechinus

You only need a z-index on the drop menu itself, not on the avatars, etc.

ETA: And on second thought that conditional I posted wouldn't be appropriate. Need more coffee. Will have to look up the right one.

Faevilangel

Quote from: Arantor on August 12, 2009, 09:58:13 AM
If you're going down that road, you could also consider making Send PM available based on user privileges too.

stop confusing me haha .... how would i do that  ???

okie dokie antechinus, i have put the zindex as 100 so it should display fine then
I am available for theme work, pm me for info

Arantor

Off hand I don't know how you would, but likely a $context[] variable. Antechinus, do you know how we'd do this?

Antechinus

$memberContext[$message['ID_MEMBER']]['can_view_profile'] = allowedTo('profile_view_any') || ($message['ID_MEMBER'] == $ID_MEMBER && allowedTo('profile_view_own'));

Those are the conditionals for the member link out of Sources/Display.php. You should be able to use this I think:

if($['context']['can_view_profile'] )

For the PM use this:

if ($context['user']['is_logged'] && $context['allow_pm'])

Faevilangel

this is what i have now


<ul class="menu2">
if($['context']['can_view_profile'] )
  echo '
<li><a href="', $scripturl, '?action=profile;u=',$context['member']['id'],'">View Profile</a></li>';
if ($context['user']['is_logged'] && $context['allow_pm'])
echo '
<li><a href="', $scripturl, '?action=pm;sa=send;u=', $context['member']['id'], '">Send Mesage</a></li>'; 
if ($context['user']['is_logged']
echo '
<li><a href="', $scripturl, '?action=buddy;u=', $context['member']['id'], ';sesc=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a> </li>';
</ul>



I am available for theme work, pm me for info

Antechinus

Syntax is wrong. Also I'd put the first conditional outside the whole menu. I'm getting brain fade so will have to knock off soon but this looks about right.


if($['context']['can_view_profile'] )


echo '

<ul class="menu2">

  <li><a href="', $scripturl, '?action=profile;u=',$context['member']['id'],'">View Profile</a></li>
<li><a href="', $scripturl, '?action=buddy;u=', $context['member']['id'], ';sesc=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a> </li>';

if ($context['user']['is_logged'] && $context['allow_pm'])
{
echo '
<li><a href="', $scripturl, '?action=pm;sa=send;u=', $context['member']['id'], '">Send Mesage</a></li>'; 
}

echo '
</ul>';
}


Faevilangel

mod installed fine but gives an error on display.template.php

syntax error, unexpected T_STRING, expecting ',' or ';'
I am available for theme work, pm me for info

Antechinus

Ok so you did take care of the line in front too?

<div class="menu titlebg2" id="profile',$message['id'],'" style="display:none;">';

    if($['context']['can_view_profile'] )
    {
        echo '
                <ul class="menu2">
                    <li><a href="', $scripturl, '?action=profile;u=',$context['member']['id'],'">View Profile</a></li>
                    <li><a href="', $scripturl, '?action=buddy;u=', $context['member']['id'], ';sesc=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a> </li>';

        if ($context['user']['is_logged'] && $context['allow_pm'])
        {
            echo '
                    <li><a href="', $scripturl, '?action=pm;sa=send;u=', $context['member']['id'], '">Send Mesage</a></li>';
        }

        echo '
                </ul>';
    }


Oh and you'll need to get rid of the hard-coded text and use language strings. Mod guys wont pass hard-coded text.

Faevilangel

Quote from: Antechinus on August 12, 2009, 10:52:09 AM
Ok so you did take care of the line in front too?

Oh and you'll need to get rid of the hard-coded text and use language strings. Mod guys wont pass hard-coded text.

<< noob .... i have no idea where to start on that at all ...... (think i got myself into deep with this)
I am available for theme work, pm me for info

Arantor

Let me talk you through language strings.

Right now you have things like 'Send Mesage' in the mod. What you do is take all these such strings (just the text) and mulch them up into a set of declarations:


$txt['menu_send_pm'] = 'Send Message';
$txt['menu_view_profile'] = 'View Profile';


Then you just add that into your modification.xml file, to be added to the end of $languagedir/Modifications.english.php.

Then in the code you substitute 'View Profile' with $txt['menu_view_profile']. It just means it's a ton easier to code for other languages.

Faevilangel

Quote from: Arantor on August 12, 2009, 04:41:31 PM
Let me talk you through language strings.

Right now you have things like 'Send Mesage' in the mod. What you do is take all these such strings (just the text) and mulch them up into a set of declarations:


$txt['menu_send_pm'] = 'Send Message';
$txt['menu_view_profile'] = 'View Profile';


Then you just add that into your modification.xml file, to be added to the end of $languagedir/Modifications.english.php.

Then in the code you substitute 'View Profile' with $txt['menu_view_profile']. It just means it's a ton easier to code for other languages.

which language file should i edit as in the default there is display.english
I am available for theme work, pm me for info

Arantor

Mods really should be editing Modifications.english.php in the first instance.

Faevilangel

Quote from: Arantor on August 12, 2009, 05:59:48 PM
Mods really should be editing Modifications.english.php in the first instance.

installed the language fine but still getting a display.template error

Quotesyntax error, unexpected '[', expecting T_VARIABLE or '$'

the mod code

<a href="#" onclick="profile_menu(\'profile', $message['id'], '\'); return false;">',$message['member']['name'],'</a>
<div class="menu titlebg2" id="profile',$message['id'],'" style="display:none;">';
if($['context']['can_view_profile'] )
{
  echo '
   <ul class="menu2">
    <li><a href="', $scripturl, '?action=profile;u=',$context['member']['id'],'"> $txt['menu_send_pm'] </a></li>
    <li><a href="', $scripturl, '?action=buddy;u=', $context['member']['id'], ';sesc=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a> </li>';       
    if ($context['user']['is_logged'] && $context['allow_pm'])
    {
     echo '
      <li><a href="', $scripturl, '?action=pm;sa=send;u=', $context['member']['id'], '"> $txt['menu_view_profile'] </a></li>';
    }
    echo '
      </ul>';
}
</div>
I am available for theme work, pm me for info

Antechinus

Finish it with echo ' </div>

Seriously you'll need to learn basic php syntax if you want to do theme and mod work. Don't mean that in a nasty sense.

Faevilangel

Quote from: Antechinus on August 12, 2009, 06:14:50 PM
Finish it with echo ' </div>

Seriously you'll need to learn basic php syntax if you want to do theme and mod work. Don't mean that in a nasty sense.

i know php a bit but it was working then wasn't and i couldn't find the error

i never learnt the code errors and what they mean but i will
I am available for theme work, pm me for info

Faevilangel

still getting error, i noticed the language bits i added hadn't been echo'd so i added the ', ,' around them and that didn't fix it

i have got myself way in over my head here, i try not to rely on people to help me but it seemed a simple mod (well i got most of it done without any help) but then adding the smf stuff just complicated it  >:(

don't think im going to be doing this again, sticking to the themes

if you want to take this over, just say as it will be much easier than trying to help me
I am available for theme work, pm me for info

Advertisement: