Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
New button between New Discussion and the pagination.
mickeybond
New
First off, is this a theme modification or a plugin? I'm wanting the "Sign In" button there when guests are browsing the page. Yes, I realize that this button already exists in the right/left (depends on theme) hand column but this is not enough for my client. What would be required to put this button there?
0
Comments
That's a tough question! Without much thinking about it, I guess the only real difference between a plugin and a theme (from developer perspective) is that a theme can do view overrides...
Whenever you make a small visual hack that you think might be useful for someone else, I would recommend to make it a plugin.
If you have a collection of visual changes, make it a theme.
What you want to achieve is a simple thing. Vanilla fires events and everytime such an event is fired, you can take action. Events are fired e.g. when database queries are prepared, when the results of such a query is processed, when information is written to the screen etc.
There is a great helper plugin: eventi. If you download and enable it, you will get a visual hint where you are able to add content. I would recommend you get that plugin and see if you get a little understanding of how it could help. If not, just post a screenshot where you would like to see such a button.
something like this
I just installed the Eventi plugin but it won't enable. i'll keep wrestling with it.
It looks like that plugin might be broken for the time being.
It's a theme thing if all you want to do is add an existing link. Just add the sign in button into your default.master.tpl or if it's a php based master the default.master.php templates.. or to the themehooks
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Awesome, I got it added but now it shows even when i'm logged in, any suggestions?
This is the php signout link which replaces the sign in one when the user signs in
$this->Menu->AddLink('SignOut', T('Sign Out'), $Authenticator->SignOutUrl(), FALSE, array('class' => 'NonTab SignOut'));
This is the sign in link
$this->Menu->AddLink('Entry', T('Sign In'), $Authenticator->SignInUrl($this->SelfUrl), FALSE, array('class' => 'NonTab'), $Attribs);
Notice that it checks for authenticating the session and that is how it knows what link to show. When it's a guest it shows as sign in and when user is logged in the link becomes log out.
You must replicate this action. If you are using a php based theme it can be done in the master, if not you need to add it to the themehooks which act as a theme plugin..it's in php.
It may be possible that simply adding the class to the link will work but it's a theory.
<a href="yoursite.com/forum/entry/signin" class="NonTab SignIn" >
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
I'm surprised you managed to put it at that place with inserting it in the default.master.tpl but anyway, the Smarty code you would need is this:
By the way, that's the code I would use:
It makes no difference if that is used in a themehooks file or in a plugin.
I have to note that I recall several new users complaining about not noticing the standard signin/signout link. While I may have personal opinion on their lack of attention I recognize that this may reflect on usability and I am all for improvement in usability.
The dilemma I have is that once the users cease to be novice the button is too intrusive...
I do like @R_J 's plug-in approach which can be further enhanced to allow admin customization or more dynamic approach.
I wasn't able to, I ended up putting it in a copy of the discussions/index.php file copied into the theme directory. The image I provided was simply a mockup attempting to show where I wanted to put it. Sorry for the confusion.
Neither of these seemed to work, adding the class to the link/button had no effect and the other code generated the following error in nginx:
2017/08/18 08:05:38 [error] 13049#0: *86955 FastCGI sent in stderr: "PHP message: PHP Fatal error: Call to a member function SignInUrl() on a non-object in /home/carolyn/vanilla/themes/bootstrap/views/discussions/index.php on line 28" while reading response header from upstream, client: 192.168.100.114, server: carolyn.vanilla.test.psg, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/php-fpm.socket:", host: "carolyn.vanilla.test.psg", referrer: "https://carolyn.vanilla.test.psg/"
line 28 being the sample code you provided. Thanks for the suggestion, I feel like I understand a little better about authentication checks.
I'm not sure where the themehooks file is to insert this into.
Most of the forum users who visit a forum so often that the get used to the look, browse it as logged in users and not as guests and so they wouldn't see that button anyway.
Creating your own theme is really easy.
1. Copy the "mobile" theme folder and give that copy a nice name, maybe "PlumS"
2. Only keep the about.php and the class.mobilethemehooks.php
3. Inspect the about.php, compare it to other about.php files of other themes and make the required changes
4. Rename the class.mobilethemehooks.php to class.plumsthemehooks.php
5. Through away everything in the themehooks file except for:
Now even remove or change those comments, change the class name to PlumSThemeHooks and insert my code from above right before the closing "}"
Basically that's it. Maybe you have to delete the *.ini files in your cache before you can see the new theme
Here is some official documentation: http://docs.vanillaforums.com/developer/theming/quickstart/
Personally I prefer learning by studying what someone else has done. You can download some themes and look at what you find there. You will see that there are some contradictions. When in doubt, do as the documentation says or ask.
Do I copy the mobile directory to inside of my bootstrap directory or simply create a copy at the same level?
You might not have seen my last post
The copy has to be on the same level /themes/PlumS
AWESOME! That works perfectly. Thank you so much for your help. So if I had to guess how to turn the sign in button into a sign out button once they were signed in would it be something along the lines of:
Theoretically yes, but Vanilla has a handy shortcut for that: https://github.com/vanilla/vanilla/blob/release/2.3/library/vendors/SmartyPlugins/function.signinout_link.php
Replace everything in the
public function discussionsController_pageControls_handler($sender) {
with this: