CodeIgniter Forums
Passing URI Segments to methods - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Passing URI Segments to methods (/thread-78671.html)



Passing URI Segments to methods - eleumas - 02-23-2021

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/incoming/controllers.html#passing-uri-segments-to-your-methods 

Someone can help me please? Thanks.


RE: Passing URI Segments to methods - InsiteFX - 02-23-2021

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


RE: Passing URI Segments to methods - eleumas - 02-24-2021

(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.


RE: Passing URI Segments to methods - Chroma - 02-25-2021

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.