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.
Related
'm working on a global site search ( autocomplete ), right now it have almost all entries ( that have uri defined ) for results, it uses js fetch and Craft element api in a json file that filter results based on a query string. Works great!
I was wondering if it's possible to add to the query categories too, i don't know if this is possible buy maybe it's a way to merge them, here is my json api code, thanks!
'search.json' => function() {
$qParam = Craft::$app->request->getParam('q');
return [
'elementType' => Entry::class,
'paginate' => false,
'criteria' => [
'uri'=> ':notempty:',
'search' => $qParam,
'orderBy' => 'score',
'limit' => 20,
],
'cache' => false,
'transformer' => function(Entry $item) {
return [
'title' => $item->title,
'url' => $item->url,
];
},
];
}
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 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.
I've added a custom order attribute and updated the onepage checkout page.
Now I'm trying to add this attribute to the new order form in the admin.
I'm trying to extend Mage_Adminhtml_Block_Sales_Order_Create_Form_Account and add a new field in the _prepareForm() method similar to the way the Group and Email fields are added.
How do I get the order attribute?
I've tried several ways but nothing works.
This is how I'm creating the custom order attribute in the mysql-install file:
$attribute = array(
'type' => 'int',
'label' => 'myattr',
'visible' => false,
'required' => false,
'user_defined' => false,
'searchable' => false,
'filterable' => false,
'comparable' => false,
);
$installer->addAttribute('order', 'myattr', $attribute);
and this is how I'm trying to get the attribute:
$res = Mage::getSingleton('core/resource');
$eav = Mage::getModel('eav/config');
$attr = $eav->getAttribute('sales/order', 'myattr');
or with this:
$entityType = Mage::getModel('eav/config')->getEntityType('order');
$entityTypeId = $entityType->getEntityTypeId();
$attribute = Mage::getResourceModel('eav/entity_attribute_collection')
->setCodeFilter('myattr')
->setEntityTypeFilter($entityTypeId)
->getFirstItem();
or this:
$order = Mage::getResourceSingleton('sales/order');
$myAttr = $order->getAttribute('myattr');
None of them work.
Have you verified that the attribute is being added to eav_attribute table in the database with the correct entity_type_id? (I think sales_order is 11 by default, but don't assume that)
At first glance, it looks like you should be using
$installer->addAttribute('sales/order', 'myattr', $attribute);
HTH,
JD
Sales/Order used to use the EAV Model which supports attributes, that was before 1.4.0 or so not sure.
I think now you should do:
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'my_column', 'decimal(12,4)');
you can still add the attribute as static field
$installer->addAttribute('order', 'my_column', array('type'=>'static'));
What I noticed after much trial-and-error was that the new attribute must have a default (non-null) value in order to work. Somehow the attribute is not writable if it has a 'NULL' value in the database. So using this attribute options array worked for me:
$attribute = array(
'type' => 'int',
'label' => 'myattr',
'default' => 0,
'visible' => false,
'required' => false,
'user_defined' => true,
'searchable' => false,
'filterable' => false,
'comparable' => false );