Welcome Guest, Not a member yet? Register   Sign In
I'm having trouble following the MVC standard.
#3

(This post was last modified: 03-09-2023, 02:27 PM by captain-sensible.)

i do mostly everthing from routes .So suppose on dev localhost , I have a view displaying : http://127.0.0.7/blogArticle/Southhall-Church-Park

via

Code:
<a href = blogArticle/Southhall-Church-Park> Southhall-Church-Park         </a>

blogArticle is connected to a route and Southhall-Church-Park is a slug I have in a slug field of slug

in app/config/Routes.php i have :

Code:
$routes->get('blogArticle/(:segment)', 'Blog::showArticle/$1');


so in the above anything in a url with blogArticle is going to get picked up

whats on the left i.e the url section is going to get passed to a controller called Blog.php and processes in a function as follows
Code:
Blog::showArticle/$1


Code:
public function showArticle($theSlug)
                    
                    {
                                         
                    $handle = new BlogModel();
                    $result= $handle->getArticle($theSlug);
                        
                    $data =[
                    'title'=>$theSlug,
                    'blog'=>$result,
                    'date'=>$this->myDate
                    ];
                            
                        
                    echo view('blogArticle',$data);
                    
                        
                    
                    }

So you can design how menu or a href links in views are handled
I use Arch Linux by the way 

CMS in Action
Reply


Messages In This Thread
RE: I'm having trouble following the MVC standard. - by captain-sensible - 03-09-2023, 02:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB