Welcome Guest, Not a member yet? Register   Sign In
Myth::Auth How to integrate provided views into app style
#1

Hi All,

let me start with a great Thanks to the Developers for this awesome lib: myth auth !

I'm wondering which is the best way to integrate the provided views (login, registration, ...) into the user app style.

Following the readme you suggest to:

Quote:override the views used by editing Config/Auth.php, and changing the appropriate values within the $views variable:
Code:
public $views = [
    'login'     => 'Myth\Auth\Views\login',
    'register'  => 'Myth\Auth\Views\register',
    'forgot'    => 'Myth\Auth\Views\forgot',
    'reset'     => 'Myth\Auth\Views\reset',
    'emailForgot' => 'Myth\Auth\Views\emails\forgot',
];



If I correctly understand I should create my own views and change the $view variable to point at them, is it correct?

What's happen in case of lib updates?

Is there a way where I can style the provided views without creating new ones and be safe for future updates?

Grazie
Reply
#2

(This post was last modified: 02-27-2020, 06:37 AM by MGatner.)

I use a view layout (also in the Config) and use that to style and wrap the provided views.

https://codeigniter4.github.io/CodeIgnit...youts.html
Reply
#3

OK I have to study how the view layouts works.

If you know some good example where to start will be really helpful.

Thanks!
Reply
#4

Layouts are great, I definitely think they are worth learning. Think of them as views that other views can “snap into”, but they have the advantage that you can add content in multiple places (whereas traditionally if you had a view the echoes the header first you would get the whole header at once). Here’s a project where I use the Auth Config file to specify my own layout yet keep the default Myth view files:
https://gitlab.oit.duke.edu/academic-tec...g/Auth.php
Reply
#5

I've followed the link to the manual section on Layouts kindly supplied by @MGatner but confess I don't understand it on first reading.

I wanted to swap the Auth navbar for a header & navbar used in other parts of the site I'm working on. I ended up changing a few lines in app/ThirdPary/myth-auth/src/Views/layout.php which did the trick but I'm pretty sure that's not a good way to do it.

PHP Code:
<?php 
/* Comment out the Myth:Auth navbar */
//view('Myth\Auth\Views\_navbar');

/* Add the standard site header file / navbar */
$data = [
    'title' => 'Login',
];
echo 
view('templates/header'$data);
?>

How should I have done it?

@MGatner if you answer & recommend your bluesmith example could you explain it a bit more please?

Grateful for any other help / advice - thanks!
Reply
#6

@MGatner Is the right way to do it in your example of Myth:Auth with the CodeIgniter Playground? Do I need to install that to find out or can it be easily explained without? Thanks!
Reply
#7

I should probably start by overriding the provided views as described in the Myth:Auth README. And as advised read up about how views can be namespaced in CodeIgniter...
Reply




Theme © iAndrew 2016 - Forum software by © MyBB