While I was learning kohana and making single article, i encountered this problem.
I wanted to get my url to look like article/post_id/slug(optional) so I made the route.
Route::set('article', '/<controller>/<article_id>(/<article_slug>(/<id1>(/<id2>(/<id3>))))', array('article_id' => '[0-9]', 'article_slug' => '[a-zA-Z0-9_]+'))
->defaults(array(
'controller' => 'article',
'action' => 'read',
));
I even tried without 3rd parameter for Route::set but anyway returns error shown in the picture.
Thanks. (:
Try without the leading /:
Route::set('article', '<controller>/<article_id>(/<article_slug>(/<id1>(/<id2>(/<id3>))))',
array(
'article_id' => '[0-9]',
'article_slug' => '[a-zA-Z0-9_]+')
)->defaults(
array(
'controller' => 'article',
'action' => 'read',
));
Related
I create small site with Yii2 basic, and I have problem, I search every times and not resolved this, I try rewrite with .htaccess file but not success.
My site have more category get from database example: house-building, car, job, computer, travel.....
I would like user click on category example: http://example.com/house-building => it access category/index?category=house-building
Current, my config/web.php as bellow.
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
#'suffix'=>'.html',
'rules' => array(
''=>'site/index',
'/login.html'=>'/users/login',
'/register.html'=>'/users/create',
### End custom url
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
],
Can you help me resolved this issues.
Thanks you.
Use this rule:
'<category:\w+>' => 'category/index'
I have created an archive page for my 'Event' custom post ape called archive-event.php.
I used the content from the standard archive.php template and it listed my 4 events in the order they were posted.
The next step was to change the order by the custom field event_date. I did this no problems. Then I wanted to not show any events that event_date had passed. The below code does this perfectly.
The issue I now have is my pagination is all messed up. I have the default reading settings set to 2 posts per page and I have a 'Load more' button to bring up the next two.
When I click 'Load more' it duplicates the two events already showing. Any ideas where I've gone wrong?
<?php
$today = date("Ymd");
$args = array (
'post_type' => 'event',
'meta_key' => 'event_date',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'event_date',
'value' => $today,
'type' => 'numeric',
'compare' => '>=',
)
),
);
$wp_query = new WP_Query( $args );
while( $wp_query->have_posts() )
{
$wp_query->the_post();
?>
<div>Content goes here</div>
<?php } wp_reset_postdata(); ?>
Depending on how the plugin builds the UI it may or may not be respecting the pagination functionality built into WordPress.
Try forcing the paged setting into your query like so:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array (
'post_type' => 'event',
'paged' => $paged, // this will be set to what WordPress thinks is the proper page to start
'meta_key' => 'event_date',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'event_date',
'value' => $today,
'type' => 'numeric',
'compare' => '>=',
)
),
);
Next, if this still doesn't work, you can test the assumption that the paged parameter isn't working for some reason by changing the default paged value like so (again, just to test):
$paged = 2; // just force it to start on the second page to see if that works
If the above test works, I would say that get_query_var() believes you're on the first page.
I just want the standard Excerpt box - not a metabox of my own creation, added to a Custom Post. The box shows up in Posts but not in Custom Posts. I've tried both of these older solutions but neither of them worked (maybe it's a WP 3.9 problem):
The custom post type name is "Scoop"
I added this to the register_post_type_scoop() $labels = array
'supports' => array('title','thumbnail','excerpt')
but it didn't work - neither did this:
add_post_type_support('Scoop', 'title');
add_post_type_support('Scoop', array('title', 'thumbnail', 'excerpt') );
Add a index value excerpt to the supports object. Below the example is:
add_action( 'init', 'create_testimonial_posttype' );
function create_testimonial_posttype(){
register_post_type( 'testimonials',
array(
'labels' => array(
'name' => __( 'Testimonials' ),
'singular_name' => __( 'Testimonial' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'clients'),
'supports' => array('title','thumbnail','editor','page-attributes','excerpt'),
)
);
}
I use default kohana 3.2 pagination module.
The search returns about 100 pages of results.
And pagination module renders all 100 links.
How to fix this?
Here is your default pagination config:
return array(
// Application defaults
'default' => array(
'current_page' => array('source' => 'query_string', 'key' => 'page'), // source: "query_string" or "route"
'total_items' => 0,
'items_per_page' => 10,
'view' => 'pagination/basic',
'auto_hide' => TRUE,
'first_page_in_url' => FALSE,
),
);
All you need is switch pagination view from pagination/basic to pagination/floating. Or you can create and use your own pagination template.
I developing magneto module, In this module i want to make a ajax request in admin panel.I don't understand were to add script and controllers.please help me.
My requirement:
When change the select box(On change) i want add some field in the form.
Mycode:
/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Edit/Tab/Form.php
$fieldset->addField('type', 'select', array(
'label' => Mage::helper('<Module>')->__('Article Type'),
'name' => 'status',
'values' => array(
array(
'value' => '',
'label' => Mage::helper('<Module>')->__('Choose'),
),
array(
'value' => 1,
'label' => Mage::helper('<Module>')->__('Normal'),
),
array(
'value' => 2,
'label' => Mage::helper('<Module>')->__('video'),
),
),
'required' => true
));
I am creating fields using this.
How can i add another field on change.
Where should i add script
Where should i add controller
I created this module using this instructions
Let this field always be on the form. But make it invisible and show when you need it.
In the same template where the form is.
Place controller in your module. On stackoverflow you can find many questions about creating your own magento module and controller.