Welcome Guest, Not a member yet? Register   Sign In
Passing URI Segments to methods
#1

Hi! I have a view with this link: 

Code:
<a href="<?php echo base_url('en/article/'.$slug);?>"> Article Title </a>

.tb_button {padding:1px;cursor:pointer;border-right: 1px solid #8b8b8b;border-left: 1px solid #FFF;border-bottom: 1px solid #fff;}.tb_button.hover {borer:2px outset #def; background-color: #f8f8f8 !important;}.ws_toolbar {z-index:100000} .ws_toolbar .ws_tb_btn {cursor:pointer;border:1px solid #555;padding:3px} .tb_highlight{background-color:yellow} .tb_hide {visibility:hidden} .ws_toolbar img {padding:2px;margin:0px}
I would like pass the $slug variable to my method named article but i have an error: Too few arguments to function App\Controllers\En\Main::article(), 0 passed in...

My method:

PHP Code:
public function article($slug)
{
$data['article'] = $this->articlesModel->where('slug'$slug)->first();

// OTHER... 
I have read here: https://codeigniter.com/userguide4/incom...ur-methods 

Someone can help me please? Thanks.
Reply
#2

Here is the tutorial link from @Inlcudebeer that will show you just how to do what you want.

How to build a basic web application with CodeIgniter 4
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(02-23-2021, 12:12 PM)InsiteFX Wrote: Here is the tutorial link from @Inlcudebeer that will show you just how to do what you want.

How to build a basic web application with CodeIgniter 4

Hi @InsiteFX thanks for reply. I read the tutorial (thanks to @Inlcudebeer) and I applied some change but the issue is not solve. The error is always the same... Huh

I have this issue only in multilang site...

Any idea?

Thanks for the support.
Reply
#4

I am not sure that you have provided enough information in the question.

What does the code look like that calls the article function. How is the parameter $slug made and what does it look like when it is both valid and invalid?

As it looks like you are passing in a non-value into the function.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB