Modifications to Login Page

I am a php novice, but have setup a site with 97 members running Elgg 2.2.23. I have changed the default title on the login screen from saying "Login" to the name of our site by adding this code into two directories in the custom_index plugin:

<p align="center" style="style="font-size: 1.8rem; font-weight: 700; color: navy; line-height: .7em; text-align: center; left-margin: auto; right-margin: auto; text-shadow: 1px 1px 3px rgba(0, 0, 0, .3);"><span align="center" style="font-size: 1.8rem; font-weight: 700; color: #2a5f99; line-height: .7em; text-align: center; left-margin: auto; right-margin: auto; text-shadow: 1px 1px 3px rgba(0, 0, 0, .3);">Olsen Park </br>Members Section</span></p>

These are the directories and files I have added to the custom_index plugin: 

views/default/resources/walled_garden.php 

views/default/resources/account/login.php 

I pasted the above code in place of 'login' in the first file here:

    'title' => elgg_echo('login'),

And also in place of 'login' pin the second file here:

echo elgg_view_page(elgg_echo('login'),

This makes the desired changes on both pages, but whenever the login page is called up by either index.php or login.php in the page title on a browser it lists the html code and not just the title of the site. How can I fix this? Thanks for any help.

  • Do I understand correctly that you changed the string 'login' => 'Log in' in the language/en.php file to the code you mentioned?

    Don't do that.

    You can create the separated code for title and header.

    For example:

    $header = ...your-mentioned-code-here...;
    
    $title = elgg_echo('login');
    
    $body = elgg_view_layout('default',  [
          'content' => $content,
          'title' => $header
    ]);
    
    
    echo elgg_view_page($title, $body);
    

    You can add your own string to language file instead of the hard coded 'login':

    'your_word' => 'Your word',

    then use:

    elgg_echo('your_word');

    Also, look at this awesome plugin.

    Learn more on the Elgg docs.

    Updates:

    Don't forget about customizing CSS instead of HTML into PHP

  • Nikolai,

    You asked:

    Do I understand correctly that you changed the string 'login' => 'Log in' in the language/en.php file to the code you mentioned?

    No, I placed these directories and files in the custom_index plugin:

    views/default/resources/walled_garden.php 

    views/default/resources/account/login.php 

    I then pasted my html code in place of 'login' in both of these files. If I changed "login" in the language file it also changed it in the login button. I also placed these folders and file in the custom_index plugin:

    /views/default/page/walled_garden.php 

    And omitted the lines:

    $header = elgg_view('page/elements/walled_garden/header', $vars);

    $footer = elgg_view('page/elements/walled_garden/footer', $vars);

    I didn't change any core files.

    I will try the translation plugin, but where would I paste the code you suggested? How can I just change the title (with my css) on the login page without using a header or footer? Thanks for your help!

    Sincerely

    Kyle Pope

    kmpope@att.net

  • Well, let's say that $header appears on the page and $title appears in the page title on a browser.

    Then you should pass $header in the layout:

    elgg_view_layout('walled_garden',  [
        'content' => $content,
        'title' => $header // add if it's not there
    ]);

    And $title in the page view:

    elgg_view_page($title, $body);

    Learn more.

  • Thank you. I have so much I still need to learn :)

  • Nikolai, you're right! Translation Editor (https://elgg.org/plugins/385116) is a great plugin!! Thanks and thank you Jerome Bakker.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking