How to pass values in url on pagination links in cakephp - pagination

This is my pagination link:
<div class="paging" style="margin-bottom:0px;">
<div class="paging_right" style="margin-bottom:0px;">
<?php echo $this->paginator->prev('<< '.__('previous', true), array('url'=>array('action'=>'ViewMember/ticket')), null, array('class'=>'disabled'));?>
|<?php echo $this->paginator->numbers(array('url'=>array('action'=>'ViewMember/ticket'),'pagecnt'=>$ticketcount,'pagenum'=>$pagenumticket));?>
<?php echo $this->paginator->next(__('next', true).' >>', array('url'=>array('action'=>'ViewMember/ticket')), null, array('class'=>'disabled'));?>
</div>
</div>
This it the url when click on links:
http://localhost/mysite/TestController/ViewMember/ticket/page:2
But i want to the url like this:
http://localhost/mysite/TestController/ViewMember/ticket/page:2/#tinfo
How can i do this?

Related

Navigate to new url from SPFX in Sharepoint online

I have a dropdown in SPFX webpart in sharepoint online. In that dropdown, onchange, I am constructing a url with # tag.
E.x. https://sharepointonine/default.aspx#2349-234234-23434
I need to navigate to this new url. I am not sure how to accomplish things.
I have tried:
window.location = url //Gives error that string is not assignable to Location
window.location.href= url//does not reload the page
window.open(url, "_self")//does not reload the page
window.location.assign(url);//does not reload the page
window.location.replace(url);//does not reload the page
Any help?
You can create element 'a' and call click to open url
let a = document.createElement('a');
a.href = 'your link to open';
a.click();
this works fine.
Also you can use react-router, as describe here
There are also redirect link:
import { Redirect } from 'react-router';
When you need to redirect to som url, you render redirect:
<Redirect to={'/to url'}></Redirect>
I test with no framework SPFX.
Test result:
Test code for your reference:
public render(): void {
this.domElement.innerHTML = `
<div class="${styles.noframeworkSpfx}">
<div class="${styles.container}">
<div class="${styles.row}">
<div class="${styles.column}">
<span class="${styles.title}">Welcome to SharePoint!</span>
<p class="${styles.subTitle}">Customize SharePoint experiences using Web Parts.</p>
<p class="${styles.description}">${escape(this.properties.description)}</p>
<a href="https://aka.ms/spfx" class="${styles.button}">
<span class="${styles.label}">Learn more</span>
</a>
<select id="option" >
<option value="test1">test1</option>
<option value="test2">test2</option>
<option value="test3">test3</option>
</select>
</div>
</div>
</div>
</div>`;
this.domElement.querySelector('#option').addEventListener('change', (e) => {
window.location.href="https://www.google.com/search?q="+e.target["value"]
})
}

Pagination not working( using wp-paginate) i m using wordpress

here is my code, I am using wp-paginate plugin in wordpress. I have tried many thing like replacing twentyfourteen_paging_nav(); with
if(function_exists('wp_paginate')) {
wp_paginate();
}
else {
twentyfourteen_paging_nav();
}
in archieve.php but still its not working.
<ul class="blog-list">
<?php
$blog = array(
'category' => '8', // post_id of category
'order' => 'Asc',
'posts_per_page' => 4,
'paged' => $paged
);
$blog_post = get_posts( $blog );
foreach ($blog_post as $post) : setup_postdata( $post );
$blog_img = $post->ID;
$blog_title = $post->post_title;
$blog_para = $post->post_content;
$blog_trimed=wp_trim_words($blog_para, 45);
$blog_name = get_post_meta($post->ID, 'author name', true);
?>
<li>
<div class="blog-content-left">
<?php echo get_the_post_thumbnail($blog_img, array(420,250)); ?>
</div>
<div class="blog-content-right">
<?php echo $blog_title; ?>
<p class="blog-date-area"><span class="blog-date"><?php echo get_the_date('M d, Y'); ?></span><span class="blog-date blog-crcl"><?php echo $blog_name; ?></span></p>
<div class="blog-para">
<p><?php echo $blog_trimed; ?></p>
</div>
<span class="read-more-btn-blue">
Read More
</span>
</div>
</li>
<?php endforeach;?>
</ul>
<?php echo wp_paginate(); ?>
Thanks for help in advance.
I didn't find any solutions, so I used pagednavi.

Displaying All Data from Custom Post Type Fields through Advanced Custom Fields

I have looked all over Google, trying to figure this out. I've made some progress but still stuck. I'm pretty new to ACF and custom post types. I have a custom post type of Attorneys that I setup through WCK. That post type has a field group with field names of attorney_photo, attorney_name and attorney_areas_of_practice. With the code below, I can get the attorney_name and attorney_areas_of_practice (repeater field) to display, but not the attorney_photo. I have the info displaying correctly on each attorneys specific page, but I need this page to be a listing of all the attorneys. Not sure what I am doing wrong with the image part.
<?php get_header(); ?>
<?php
$args = array(
'posts_per_page' => 30,
'order' => 'ASC',
'orderby' => 'title',
'post_type' => 'attorneys'
);
query_posts($args);
if ( have_posts() ) :
?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="attorney-preview">
<?php $photo = get_post_meta($post->ID,'attorney_photo', true); ?>
<img src="<?php echo $photo; ?>" />
<p><strong><?php echo get_post_meta($post->ID,'attorney_name', true); ?></strong></p>
<ul>
<?php
while ( have_rows('attorney_areas_of_practice') ) : the_row();
$attorney_area_of_practice = get_sub_field('attorney_area_of_practice');
echo "<li>" . $attorney_area_of_practice . "</li>";
endwhile;
?>
</ul>
</div><!-- .attorney-preview -->
<?php endwhile; ?>
<?php endif; ?>
<?php
wp_reset_query(); // Restore global post data stomped by the_post().
?>
<?php get_footer(); ?>
When you add image field through ACF plugin there are some options of return value. For example return value is: image object or return value is: image url, in your case return value might be selected as image object, not image url. That is why here with your code is being returned an array rather than only url. To get only image url from this array, please write as following a bit change:
<?php $photo = get_post_meta($post->ID,'attorney_photo', true); ?>
<img src="<?php echo $photo['url']; ?>" />
Try this
<?php query_posts(array('posts_per_page' => 30,'order' => 'ASC','orderby' => 'title','post_type' => 'attorneys'));
if (have_posts()) : while (have_posts()) : the_post();
$attorney_photo = get_post_meta($post->ID, 'attorney_photo', true);
$attorney_name = get_post_meta($post->ID, 'attorney_name', true); ?>
<div class="attorney-preview">
<img src="<?php echo $attorney_photo; ?>" />
<p><strong><?php echo $attorney_name; ?></strong></p>
<ul>
<?php
while ( have_rows('attorney_areas_of_practice') ) : the_row();
$attorney_area_of_practice = get_sub_field('attorney_area_of_practice');
echo "<li>" . $attorney_area_of_practice . "</li>";
endwhile;
?>
</ul>
</div><!-- .attorney-preview -->
<?php endwhile; endif; ?>
<?php
wp_reset_query(); // Restore global post data stomped by the_post().
?>

How to display content from a child page within a hierarchial custom post type?

I have a hierarchical custom post type. It has 6 pages, and each page has 3 child pages.
When viewing one of the 6 pages, I need to display content (a title and excerpt) from each of its 3 child/descendent pages.
Here is my current loop:
<?php if(have_posts()):?>
<?php query_posts('&post_type=how-we-do-it&post_parent=0');?>
<?php while(have_posts()):the_post();?>
<?php $color = get_post_meta( get_the_ID(), 'pointb_how-we-do-it-color', true ); ?>
<div class="section">
<div class="title">
<h1 style="background:<?php echo $color;?> !important;">
<?php the_title();?>
</h1>
</div>
<div class="content">
<div class="how-<?php the_slug();?>">the summary here. and here is child content:
<div class="child">child content should be here.</div>
</div>
</div>
</div>
<?php endwhile;?>
<?php wp_reset_query(); ?>
<?php endif;?>
I have tried numerous different approaches to try and accomplish what I need, but none of them work within the custom post type. Here are some of the various methods I have tried:
I tried the suggested code on this page: http://wordpress.org/support/topic/display-child-pages-title-amp-content-on-parent-page
I also tried the following code:
$pageChildren = get_pages('child_of='.$post->ID');
if ( $pageChildren ) {
foreach ( $pageChildren as $pageChild ) {
echo '<h2>'. $pageChild->post_title.'</h2>
';
if ($pageChild->post_excerpt){
echo ''.$pageChild->post_excerpt.'
';
}
}
}
I've tried a number of other methods that I didn't bother saving, so I can't show them.
I'm at the point where I am getting frustrated with this and thought I'd throw it out here to get some fresh perspectives.
The issue with your first sample is that you call if(have_posts()) before you reconstruct the query.
The second sample has a dangling ' after $post->ID.
Try this:
$pageChildren = get_posts( 'post_type=how-we-do-it&post_parent='.$post->ID );
Based on some comments from MarZab above, I got thinking about the post ID.
I made the following tweak to the block of code I originally posted above, and now it works perfectly:
$pageChildren = get_pages('child_of='.$post->ID');
Is now:
$post_id = get_the_ID();
$pageChildren = get_posts( 'post_type=how-we-do-it&echo=0&post_parent='.$post_id );

What is the link to redirect after successful payment at payment gateway in opencart?

I've implemented payment module in Opencart based on BankTransfer module.
Requirement for payment gateway is to submit with get request a successurl and errorurl. Those URL are for successful order and canceled order.
Algorithm:
Customer gets to the order checkout.
Click confirm order
Gets redirected to localhost/opencart/testkzm.php, where values are printed out and there's a link with to which i should redirect in case of success.
QUESTION: What is the link to redirect after successful payment at payment gateway?
Approach:
I've naively thought that http://example.com/opencart/index.php?route=checkout/success is the success link. It's only shows confirmation message, but order is not placed in the system. I understand that there's no way to give external link that will automatically know which order to confirm, so should i pass encrypted unique values in successurl, so on return i can decrypt them and confirm order?
Explanation of files:
banktransfer.php is file opencart gets information from system such
order id, amount of the order and etc.
banktransfer.tpl is template
file for rendering page in browser.(Actual front-end)
testkzm.php is
simple file that i wrote to test that i get correct values from
system.
testkzm.php is
simple file that i wrote to test that i get correct values from
system.
banktransfer.php in controller/payment
class ControllerPaymentBankTransfer extends Controller {
protected function index() {
$this->language->load('payment/bank_transfer');
$this->data['text_instruction'] = $this->language->get('text_instruction');
$this->data['text_description'] = $this->language->get('text_description');
$this->data['text_payment'] = $this->language->get('text_payment');
//Modified things for KZM
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
$this->data['orderIdKZM'] = $this->session->data['order_id'];
$this->data['amountKZM'] = $order_info['total'];
$this->data['merchantIdKZM'] = $this->language->get('merchantIdKZM');
$this->data['currencyKZM'] = $this->language->get('currencyKZM');
$this->data['titleKZM'] = $this->language->get('titleKZM');
$this->data['successuUlKZM'] = $this->language->get('successUrlKZM');
$this->data['errorUrlKZM'] = $this->language->get('errorUrlKZM');
$this->data['dateKZM'] = $this->language->get('dateKZM');
$this->data['signstrKZM'] = $this->language->get('signstrKZM');
$this->data['verKZM'] = $this->language->get('verKZM');
//KZM
$this->data['button_confirm'] = $this->language->get('button_confirm');
$this->data['bank'] = nl2br($this->config->get('bank_transfer_bank_' . $this->config->get('config_language_id')));
$this->data['continue'] = $this->url->link('checkout/success');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/bank_transfer.tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/bank_transfer.tpl';
} else {
$this->template = 'default/template/payment/bank_transfer.tpl';
}
$this->render();
}
public function confirm() {
$this->language->load('payment/bank_transfer');
$this->load->model('checkout/order');
$comment = $this->language->get('text_instruction') . "\n\n";
$comment .= $this->config->get('bank_transfer_bank_' . $this->config->get('config_language_id')) . "\n\n";
$comment .= $this->language->get('text_payment');
$this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('bank_transfer_order_status_id'), $comment, true);
}
}
banktransfer.tpl
<h2><?php echo $text_instruction; ?></h2>
<div class="content">
<p><?php echo $text_description; ?></p>
<p><?php echo $bank; ?></p>
<p><?php echo $text_payment; ?></p>
<p><?php echo $orderIdKZM; ?></p>
<p>
<?php
$titleKZM = $titleKZM.$orderIdKZM;
$merchantIdKZM = '23';
$currencyKZM = 'KZT';
$successUrlKZM = '';
$erroUrlKZM = '';
$dateKZM = $merchantIdKZM.$orderIdKZM.$amountKZM.$currencyKZM;
?></p>
</div>
<div class="buttons">
<div class="right">
<form action="http://example.com/opencart/testkzm.php" method="get">
<input type="hidden" name="merchantIdKZM" value="<?php echo $merchantIdKZM; ?>">
<input type="hidden" name="orderIdKZM" value="<?php echo $orderIdKZM; ?>">
<input type="hidden" name="amountKZM" value="<?php echo $amountKZM; ?>">
<input type="hidden" name="currencyKZM" value="<?php echo $currencyKZM; ?>">
<input type="hidden" name="successUrlKZM" value="<?php echo $successUrlKZM; ?>">
<input type="hidden" name="errorUrlKZM" value="<?php echo $errorUrlKZM; ?>">
<input type="hidden" name="signstrKZM" value="<?php echo $signstrKZM; ?>">
<input type="hidden" name="verKZM" value="<?php echo $verKZM; ?>">
<input type="button" value="<?php echo $button_confirm; ?>" id="button-confirm" class="button" />
</form>
</div>
</div>
<script type="text/javascript"><!--
$('#button-confirm-s').bind('click', function() {
$.ajax({
type: 'get',
url: 'index.php?route=payment/bank_transfer/confirm',
success: function() {
location = '<?php echo $continue; ?>';
}
});
});
//--></script
testkzm.php
merchantID <?php echo $_GET["merchantIdKZM"]; ?><br>
orderID <?php echo $_GET["orderIdKZM"]; ?> <br>
amount <?php echo $_GET["amountKZM"]; ?><br>
currency <?php echo $_GET["currencyKZM"]; ?> <br>
successURL <?php echo $_GET["successUrlKZM"]; ?><br>
errorURL <?php echo $_GET["errorUrlKZM"]; ?> <br>
signstr <?php echo $_GET["signstrKZM"]; ?><br>
ver <?php echo $_GET["verKZM"]; ?> <br>
<div class="buttons">
<div class="right">
asdfas
</div>
</div>
The return URL from the payment gateway is completely up to yourself and the payment gateway's methodology. In general, if you can pass a url to the payment gateway to return for true and/or false for the success of the transaction, you would get it to use a method of your payment gateways controller, such as http://yourstore.com/index.php?route=payment/payment_gateway/success where you can then process the payment, and update the order status accordingly
If you want to then go to the checkout success page, you would use $this->redirect($this->url->link('checkout/success', '', 'SSL')). If it fails, you should redirect back to the checkout pages where the customer can quickly skip through the various pages which should already have their details filled in, and they can then try again
The success url is checkout/success as you thought.
The payment module should confirm the payment before goes to success page. Bank Transfer module do the confirmation by using AJAX (as you can see in banktransfer.tpl) to calls confirm function in banktransfer.php.
It's better if you use another payment gateway module (like pp_standard, moneybookers, paymate, etc) as your starting point instead Bank Transfer because they are more resemble with your custom payment gateway module requirements.
I made this just added simple redirect code to start
<?php
header('Location:http://yoursite location');
exit;
?>
in view/template/yourtemplate/common/success.tpl

Resources