eZ Community » Forums » Developer » How to add a login box to the...
expandshrink

How to add a login box to the frontpage (eZPublish 5.4)

How to add a login box to the frontpage (eZPublish 5.4)

Monday 27 April 2015 3:27:05 am - 8 replies

Hi,

I have recently set up eZPublish with the DemoBundle, and overridden the template to make the frontpage look how I want it.

My next step is to have a log in box on the front page. I want to use the same functionality (for now) as going to the admin login page, so I assumed it was just involves copying the code for the actual login box into my template and then restyling the css, but I cannot get it to work.

 

This seems to be a useful article https://doc.ez.no/display/EZP/Authentication#Authentication-AuthenticationusingSymfonySecuritycomponent but I have still not been able to get it to work yet.

 

Any help gratefully received!!

 

Barry

Monday 27 April 2015 6:16:29 am

Hello Barry,

I think it would help us all to know in more detail specifically what errors your getting or what problems your encountering ie: what can you not get to work happy.gif Emoticon

Cheers,
Heath

Tuesday 28 April 2015 1:08:01 am

Of course. Thank you for your help again Heath

I have already been able to override the EzPublishDemoBundle template and its CSS, and that is working perfectly now.

(see http://share.ez.no/forums/ez-publish-5-platform/best-way-to-use-override-system-in-ez-publish-5)

 

I have been able to really make my landing page look  good using these CSS overrides, but now I am trying to add a login box to that front page, which will use the Symfony functions as you would use on the _admin page. The only thing I want to change is how it looks and I will use CSS for this. All functionality will stay the same, and it will redirect to the normal admin section, will I will also redesign (CSS only).

This is what I have tried so far (based on this guide https://doc.ez.no/display/EZP/Authentication#Authentication-AuthenticationusingSymfonySecuritycomponent):

 

 

I have copied the DemoBundle::Security:login.html.twig file to the same destination in my own bundle.

I have added a twig block called "login_content" to my own bundle pagelayout.html.twig to bring the login box to my front page.

I have tried several different configurations in the ezpublish.yml user/layout and user/login_template

 

So far I cannot get the login box to appear on my front page, even as a template without functionality. I know that I have missed something out, maybe more than one thing. But I cannot work out where to go next. The error I am getting is:

 Variable "layout" does not exist in "EzPublishCoreBundle:Security:login.html.twig"

 

and then I tried to add an include      {% include 'BaanMagpieBundle::Security:login.html.twig' %}   in the head area of my own pagelayout.html.twig and I get the following:

Template "BaanMagpieBundle::Security:login.html.twig" is not defined () in eZDemoBundle::pagelayout.html.twig at line 17.

page 17 is where the include sits that I have just mentioned.

 

I think that is all the steps so far. Please let me know if you need any more information

 

Please help in any way you can

Many thanks

 

Barry

Tuesday 28 April 2015 8:58:02 am

Hello Barry,

Thank you for your detailed reply. Everything you shared was fantastic! Please use this level of detail in the future in your forum posts as it really helps everyone, especially me.

It seems your confirming that my suggestions in http://share.ez.no/forums/ez-publish-5-platform/best-way-to-use-override-system-in-ez-publish-5 helped you solve your pagelayout and css problems. Which is really great news to hear, I wasn't sure because you never posted any follow up replies to my detailed suggestions and examples. 

Would you mind going back through your post history and replying to the older threads and indicate clearly which replies / advice was helpful in solving the problems presented within the posts?

I make this request not for myself but for the other readers of these posts in the community who might read your posts looking for -confirmed- answers. So your help in confirming answers work in the forum threads you create (and in general) would be a really helpful way for you to contribute that little extra that will help other newbie users for years to come.

I took the time tonight, instead of going to bed early (again, lol) to work through updating my example bundle showing how to override the demobundle templates to provide login template customizations. Here is the commit diff which shows specifically what was required to add for me (and everyone else) to be able to provide for this level of customization.

https://github.com/brookinsconsulting/BCPageLayoutOverrideTestBundle/commit/c8c0324554c815a55ddbc398eed43fb092ea6f9c

I'm short for time so I won't explain everything (and why / what is required / etc) and this time I'll let the code speak for itself. I hope this is ok, the commit diff should speak for itself, if not just let me know if you have questions and I'll be happy to explain further how all this works and why.

In short I made two specific additions. I added support to our example ezdemo override bundle to provide a custom template for uri /login view -and- added custom template(s) and controllers required to customize the pagelayout header login form template (available on almost all pages using this pagelayout).

Overall, the research / implementation testing was not too hard. It was actually more work dealing with the following hx:include error with ezp 2014.11 and cleaning out all the extra implementation I thought might be required (as I prepared the above commit). You should have few troubles but if you do, just let us know.

One note to consider. I was using a tar.gz download of the 2014.11 community build and ran into the problems described in this thread in getting the header login links to render / display using my custom template on the custom pagelayout.

In the html inspection, I would see something like: 

<hx:include src="/_fragment?_path=serialized_siteaccess%3DO%253A38%253A%2522eZ%255CPublish%255CCore%255CMVC%255CSymfony%255CSiteAccess%2522%253A3%253A%257Bs%253A4%253A%2522name%2522%253Bs%253A16%253A%2522ezdemo_site_user%2522%253Bs%253A12%253A%2522matchingType%2522%253Bs%253A8%253A%2522host%253Amap%2522%253Bs%253A7%253A%2522matcher%2522%253BO%253A55%253A%2522eZ%255CPublish%255CCore%255CMVC%255CSymfony%255CSiteAccess%255CMatcher%255CMap%255CHost%2522%253A3%253A%257Bs%253A6%253A%2522%2500%252A%2500map%2522%253Ba%253A0%253A%257B%257Ds%253A13%253A%2522%2500%252A%2500reverseMap%2522%253Ba%253A0%253A%257B%257Ds%253A6%253A%2522%2500%252A%2500key%2522%253Bs%253A7%253A%2522ezp5dev%2522%253B%257D%257D%26_format%3Dhtml%26_locale%3Den_US%26_controller%3DBCPageLayoutOverrideTestBundle%253ABCPageLayoutOverrideTest%253AuserLinks&amp;_hash=Xp%2BOCO1d%2FG7ofF%2FtK3s710tHE3SPfI4jDXl%2BccNNT18%3D" class="include_200"></hx:include>

But I would not see the header login form html needed. So I ran the link provided in the hx:include src and found it triggered the following documented error:

http://share.ez.no/forums/ez-publish-5-platform/strict-standards-error

If your running the same version as me you will need to solve this problem (which I document in the above thread) or the header login links will not display as the hx:include fails internally with a 500 error in 2014.11. Also worth noting that they say upgrading should also properly solve this problem.

Instead for me, since this is just a throwaway dev / test installation; I just kernel hacked the changes required to be able to continue building my example and avoided properly solving the issue by doing a proper upgrade (which no one else should do on a real installation). 

Please let us know what you think of this tested example providing the functionality you are trying to implement.

I hope this helps!

Cheers,
Heath

Tuesday 28 April 2015 12:23:51 pm

Thank you so much Heath. It sounds like that should work but I am out for the day so cannot test it until this evening. Specifically, do you think that should solve the login box problem? I will make sure that I add the level of detail in the future as I can now see the benefits of this. Is there a way that one can write posts as suggestions for entry into the official documentation? This would be the first place the noobie users would look, and would be an excellent reference to go back on if you can't remember what you did last time!

Tuesday 28 April 2015 1:21:58 pm

Hello Barry,

Take your time, no rush on my part with testing our work / suggestions / examples.

Based on what you said you wanted to do, I was able to implement the same thing as you using the demobundle as a reference and our existing testing override bundle as an container for the required custom templates. In short, I did it and it worked on all levels .. and I didn't even know what I was supposed to do either, I just sat down and did the work and all the pieces fell together; Then I made a clean commit for you / everyone with a need to be able to study and learn from. 

I think it will work for you. I mean I know your not going to use it outright, no one should except for testing, our bundle just an example that you can copy and paste the code from into your own custom bundle and study to learn from.

If I were you, I would install the bundle, test to see that it works for you (overrides load / see my custom template text (in headers or bold)), then remove the bundle and then re-implement the code it provides into your own custom bundle. Fairly simple, just takes time and patience.

Today you can make comments (when logged in) on existing documentation pages, if you like. I think this is always a good idea! We've been without comment privileges on legacy documentation for far too many years so it's very nice that the new stack documentation (using confluence) makes it simple to add comments.

As for new pages of documentation, today, I'm not sure the best way to recommend such additions.

You could write some documentation and publish it on eZpedia.org (The free eZ documentation wiki) that anyone can edit / publish their own documentation into. We recently created a category for new stack specific documentation (as part of a recent upgrade), http://www.ezpedia.org/en/platform

You could also write some documentation and post it as a blog on share.ez.no/blogs as others have been doing and within the blog post ask out loud that something similar be added to the official documentation and where (in terms of placement) it should go.

I prefer in general to discourage using blog posts as a substitute for real documentation, as I feel (as others on the eZpedia Board) that blogs (like forum threads) while useful at some level, are a poor form of documentation and that a real documentation articles on a topic on eZpedia are always more visible, easier to find later and in many other ways a better way of sharing / collaborating on community documentation.

Or just ask one of the eZ Crew; I'm sure they will know exactly what you can do to help.

I hope this helps!

Cheers,
Heath

Sunday 03 May 2015 1:05:12 pm

Thanks heath.

 

It worked exactly as expected. I have since spent some time analysing how the code has put together, and I feel I have a much better understanding now.

So thanks on all levels.

 

Barry

Sunday 03 May 2015 4:22:22 pm

Hello Berry,

Excellent! I'm very pleased I was able to help you get started and hopefully start you off towards real productivity with eZ Publish!

Your very welcome. I have had a lot of fun answering your questions and helping you.

You know Berry, I want to thank you as well. Because of you asking questions about how to use eZ Publish 5, I was inspired to work harder to learn more about the inner workings of eZ Publish 5, to be able to answer your questions and provide detailed copy & paste examples.

It's been an exciting transition for me and I really do have you to thank for the opportunities you have presented within your questions.

So from the bottom of my heart I wish to express my gratitude to you for helping me. Thank you! happy.gif Emoticon

I look forward to your future questions here in the share.ez.no forums.

Take it eZ!

Cheers,
Heath

Monday 20 July 2015 1:07:53 pm

The reply has been removed because of violation of forum rules.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from