{"id":1575,"date":"2022-08-30T15:17:40","date_gmt":"2022-08-30T15:17:40","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/27\/kohana-3-2-routeget-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:17:40","modified_gmt":"2022-08-30T15:17:40","slug":"kohana-3-2-routeget-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/kohana-3-2-routeget-collection-of-common-programming-errors\/","title":{"rendered":"Kohana 3.2 Route::get-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m trying to add simple links in kohana inside a view inside a loop .<\/p>\n<p>Here is the code i have :<\/p>\n<pre><code>echo HTML::anchor(Route::get('parent')-&gt;uri(array('id' =&gt; $parent-&gt;id)), HTML::chars($parent-&gt;email))\n<\/code><\/pre>\n<p>Now this return a link to root because<\/p>\n<pre><code>Route::get('parent')-&gt;uri(array('id' =&gt; $parent-&gt;id)\n<\/code><\/pre>\n<p>returns an empty string .<\/p>\n<p>Now if If i modify my Route::get to :<\/p>\n<pre><code>Route::get('parent')-&gt;uri(array(\n                      'controller' =&gt; 'parent' , \n                      'action'     =&gt; 'index'  , \n                      'id'         =&gt;  $parent-&gt;id))\n<\/code><\/pre>\n<p>I get the correct link .<\/p>\n<p>Question : Why Kohana is not able to get the correct link knowing that in my bootstrap i have the following :<\/p>\n<pre><code>Route::set('parent', '((\/(\/)))')\n-&gt;defaults(array(\n'controller' =&gt; 'parent',\n'action'     =&gt; 'index',\n));\n<\/code><\/pre>\n<p>And that : Route::get(&#8216;parent&#8217;) returns :<\/p>\n<pre><code>: object(Route) = \n  _callback: undefined = NULL\n  _uri: string = \"((\/(\/)))\"\n  _regex: array = \n  _defaults: array = \n    controller: string = \"parent\"\n    action: string = \"index\"\n  _route_regex: string = \"#^(?:(?P[^\/.,;?\\\\n]++)(?:\/(?P[^\/.,;?\\\\n]++)(?:\/(?P[^\/.,;?\\\\n]++))?)?)?\\$#uD\"\n<\/code><\/pre>\n<ol>\n<li>\n<p>Due to Kohana 3.2 doc (http:\/\/kohanaframework.org\/3.2\/guide\/api\/Route#uri) <code>Route::uri() method Generates a URI for the current route based on the parameters given.<\/code>. So if you want this to work you have to define ALL the route parameters.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-27 11:52:59. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m trying to add simple links in kohana inside a view inside a loop . Here is the code i have : echo HTML::anchor(Route::get(&#8216;parent&#8217;)-&gt;uri(array(&#8216;id&#8217; =&gt; $parent-&gt;id)), HTML::chars($parent-&gt;email)) Now this return a link to root because Route::get(&#8216;parent&#8217;)-&gt;uri(array(&#8216;id&#8217; =&gt; $parent-&gt;id) returns an empty string . Now if If i modify my Route::get to : Route::get(&#8216;parent&#8217;)-&gt;uri(array( &#8216;controller&#8217; =&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1575","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1575"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1575\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}