Joomla archive by year? - joomla

I posted this question before, but it got drowned and barely got any views so I figured I'd try one more time.
This seems like such a strange thing to not exist yet but I've been looking for ages. Is there an archive plug-in or component, or any way really, to simply sort the archive by year? All I want is to display columns for each year, with the year displayed above each column, containing a (clickable) list of archived titles. I'm using Joomla 2.5.
Anyone know how to do this? Whether it's through a plug-in/component or editing the existing archive code; don't care how, just want to get it done. Any help would be much appreciated.

You could try these extensions:
JExtBOX Article History - 5$
Demo : http://demo.jextbox.com/
Monthly Archive
Demo: http://www.joomla357.com/demo/monthly-archive.html - ?$
Mod LCA
Demo: http://www.jonijnm.es/web/mod-lca.html - free

This might not be an ideal solution and not too clean either, but I used Monthly Archive and changed the getMonths() method in the monthlyarchiveclass to include this:
$byYear = array();
foreach($month_years_unique as $month_year){
$year = explode('-',$month_year);
$byYear[$year[1]] = array();
}
foreach($results_months as $result){
$year = $result['year'];
$id = $result['id'];
$byYear[$year] = array(
$id => $result,
);
}
if(count($byYear) != 0){
foreach($byYear as $year => $value){
$html .= '<div class="archivecolumn"><h1>'.$year.'</h1>';
$html .= '<ul class="itemlist">';
foreach($value as $item){
$cat = $this->getCatName($item['catid']);
$link = 'index.php/' . $cat . '/' . $item['id'] . '-' . $item['alias'];
$html .= '<li>';
$html .= ''.$item['title'].'';
$html .= '</li>';
}
$html .= '</ul>';
$html .= '</div>';
}
} else {
$html .= 'No archived works.';
}

Related

ebay-api "findItemsByKeywords" pagination in codigniter 3

Can anyone help me with this issue?
I'm making an API call with 50 entries per page.
I get results, but how can i display the next page ?
How to use pagination ? i don't have a clue where to start.
I really need some help here.
Thanks
This is the controller
if (!empty($_POST['submit'])) {
$aaa = $_POST['kikozasearch'];
}else {
$aaa = $_POST['kikozasearch'];
}
// API request variables
$endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1'; // URL to call
$version = '1.0.0'; // API version supported by your application
$appid = ''; // Replace with your own AppID
$globalid = 'EBAY-US'; // Global ID of the eBay site you want to search (e.g., EBAY-DE)
$query = $aaa; // You may want to supply your own query
$safequery = urlencode($query); // Make the query URL-friendly
$i = '0'; // Initialize the item filter index to 0
$apicall = "$endpoint?";
$apicall .= "OPERATION-NAME=findItemsByKeywords";
$apicall .= "&SERVICE-VERSION=$version";
$apicall .= "&SECURITY-APPNAME=$appid";
$apicall .= "&GLOBAL-ID=$globalid";
$apicall .= "&keywords=$safequery";
$apicall .= "&paginationInput.pageNumber=$currentpage";
$apicall .= "&paginationInput.entriesPerPage=50";
//$apicall .= "&paginationOutput.totalPages";
$apicall .= "$urlfilter";
// Load the call and capture the document returned by eBay API
$resp = simplexml_load_file($apicall);
// Check to see if the request was successful, else print an error
if ($resp->ack == "Success") {
$results = '';
// If the response was loaded, parse it and build links
foreach($resp->searchResult->item as $item) {
$pic = $item->galleryURL;
$link = $item->viewItemURL;
$title = $item->title;
// For each SearchResultItem node, build a link and append it to $results
$results .= "<div><img src=\"$pic\"></td><td>$title$pag</div>";
}
}
// If the response does not indicate 'Success,' print an error
else {
$results = "<div class='alert alert-danger'><h4>Oops! The request was not successful. Make sure you are using a valid ";
$results .= "AppID for the Production environment.</h4></div>";
}
echo "We found: ".$resp->paginationOutput->totalEntries . " resaults!";
echo "<div class='alert alert-info'>".$results."</div>";
// echo $resp->paginationOutput->entriesPerPage;
// echo "<br>";
// echo $resp->paginationOutput->totalEntries;
// echo "<br>";
// echo $resp->paginationOutput->totalPages;
echo $currentpage;
echo "/".$resp->paginationOutput->totalPages;
echo "<br />";
$totalpages = $resp->paginationOutput->totalPages;
Here is the post request
<script>
$(document).ready(function(){
$('#form').on('submit', function(info){
info.preventDefault();
$.post('<?php echo base_url();?>index.php/ebayapps/searchitem',
$('#form').serialize(),
function(data){
$('#resaults').html(data);
}
);
}); // keyup
});
</script>
If I understand correctly, you want to load more than one page of results. In this case, you will need to make numerous API requests, depending on the total number of pages you wanted to retrieve in the first place.
So say you want four pages - you need to run your function four times and increment paginationInput.pageNumber in each loop.
I hope this helps.

Paypal Notify URL returned nothing using CodeIgniter

First of all I had my sandbox merchant account configured to receive IPN. I will show you the first half of my codes that is sent to Paypal:
function process() {
$my_email = 'jaylimix-facilitator#hotmail.com';
$item_name = $this->input->post('item_name');
$amount = $this->input->post('amount');
$function = $this->input->post('function');
$return_url = base_url() . 'order/'.$function;
$cancel_url = 'http://cancel.com';
$notify_url = base_url() . 'test';
$querystring .= "?business=" . urlencode($my_email) . "&";
$querystring .= "item_name=" . urlencode($item_name) . "&";
$querystring .= "amount=" . urlencode($amount) . "&";
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$querystring .= "$key=$value&";
}
$querystring .= "return=" . urlencode($return_url) . "&";
$querystring .= "cancel_return=" . urlencode($cancel_url) . "&";
$querystring .= "notify_url=" . urlencode($notify_url);
header('location:https://www.sandbox.paypal.com/cgi-bin/webscr' . $querystring);
}
The customer is redirected to PayPal to complete payment. When the Pay button is clicked, I checked to see if any POST variable is received:
class Test extends CI_Controller{
function index(){
foreach ($_POST as $key => $value) {
echo $key . ' ' . $value . '<br/>';
}
}
}
But there is none received and I do not know where the problem is. Please give your advices, thanks!
When the Pay button is clicked, I checked to see if any POST variable is received:
It isn't. PayPal invokes the notifyURL separately at a later time, not 'when the Pay button is clicked'. When PayPal returns to your site, all you know is that they have been to PayPal. In any case you shouldn't do anything of value for the customer until PayPal tells you that you actually have the money.

build category tree for categories and sub categories

i am trying to built category tree for the categories and sub categories in custom admin module, if possible to override the default category tree present in edit tab of product.
Below is the code which i am working, it is able to build category tree but it lack the checkbox ability. any sugestion would be appreciated
<?php
$rootcatId= Mage::app()->getStore()->getRootCategoryId();
$categories = Mage::getModel('catalog/category')->getCategories($rootcatId);
function get_categories($categories) {
$array= '<ul>';
foreach($categories as $category) {
$cat = Mage::getModel('catalog/category')->load($category->getId());
$count = $cat->getProductCount();
$array .= '<li>'.
'<a href="' . Mage::getUrl($cat->getUrlPath()). '">' .
$category->getName() . "(".$count.")</a>\n";
if($category->hasChildren()) {
$children = Mage::getModel('catalog/category')->getCategories($category->getId());
$array .= get_categories($children);
}
$array .= '</li>';
}
return $array . '</ul>';
}
echo get_categories($categories); ?>
Please clarify your question as it's bad idea to override core functionality because same function is used by different modules instead you can check functionality of these
app/design/adminhtml/default/default/template/catalog/product/edit/categories.ph‌​tml app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Categories.php
and then reflect these to your template files

Errors, warning, notices with a cross to hide them using Jquery. How to extend the core message class in a right way to achieve this?

I want my error, warning, notification messages on frontend to extend a bit. So,
I need to override
Mage_Core_Block_Messages
class's
public function getGroupedHtml()
{
$types = array(
Mage_Core_Model_Message::ERROR,
Mage_Core_Model_Message::WARNING,
Mage_Core_Model_Message::NOTICE,
Mage_Core_Model_Message::SUCCESS
);
$html = '';
foreach ($types as $type) {
if ( $messages = $this->getMessages($type) ) {
if ( !$html ) {
$html .= '<' . $this->_messagesFirstLevelTagName . ' class="messages">';
}
$html .= '<' . $this->_messagesSecondLevelTagName . ' class="' . $type . '-msg">';
$html .= '<' . $this->_messagesFirstLevelTagName . '>';
foreach ( $messages as $message ) {
$html.= '<' . $this->_messagesSecondLevelTagName . '>';
$html.= '<' . $this->_messagesContentWrapperTagName . '>';
$html.= ($this->_escapeMessageFlag) ? $this->htmlEscape($message->getText()) : $message->getText();
$html.= '</' . $this->_messagesContentWrapperTagName . '>';
$html.= '</' . $this->_messagesSecondLevelTagName . '>';
}
$html .= '</' . $this->_messagesFirstLevelTagName . '>';
$html .= '</' . $this->_messagesSecondLevelTagName . '>';
}
}
if ( $html) {
$html .= '</' . $this->_messagesFirstLevelTagName . '>';
}
return $html;
}
to extend the html and put a cross in the message box and implement Jquery. logic: on click close hide error box. So customers can upon click hide the box.
I believe this class doesn't have any template file and the html it is rendering from the this block class itself as I can see in getGroupedHtml() method.
So, I am going to override this method and add more html.
Also, I want to do this only for one theme and not in Admin
What is the better way to achieve this?
Please suggest me something. Thanks
You could accomplish this without overriding anything and by just going for JavaScript (jQuery) only.
Here is a simple script that should do the job.
var messages = jQuery("ul.messages li[class$='-msg']");
messages.each(function(){
var message = jQuery(this);
message.find('span').append('<span class="close">X</span>');
});
messages.on('click', function(){
var message = jQuery(this).closest("li[class$='-msg']");
message.hide();
});
The script adds a 'X' to the end of every message and removes (hides) the message when it's clicked.
The only thing left to do is to give the cross (span X) some styling.
You could place this in your footer template for the correct theme.

CodeIgniter - Checking to see if a radio button is checked in the database

Im having a bit of trouble putting some code together ... What im trying to do is add some code to the code i have at the moment to check radiobuttons that are checked in the database.
The code i have at the moment takes all roles from the database, outputs them using a foreach statement, but also splits the results into 2 columns, this is what i have at the moment.
<?php
$i = 0;
$output = "";
foreach($roles as $row){
if($i > 0){
$i = 0;
}
if($i == 0) {
$output .= "<div class='box'>";
}
$output .= '<div class="row">';
$output .= ' <input name="_'.$row->key.'" type="radio" id="'.$row->key.'" class="radio" />';
$output .= ' <label for="'.$row->key.'" style="text-transform: lowercase;">'.$row->name.'</label>';
$output .= '</div>';
if($i ==0) {
$output .= "</div>";
}
$i++;
}
if($i != 1) {
$output .= "</div>";
}
echo $output;
?>
Ok, so what i want to do is check the radio button in the code that i posted, only when there is a match in the database, So to get the values that were checked by the user, i use the following.
Model
function get_roles_by_id($freelancerid)
{
$query = $this->db->query('SELECT * FROM '.$this->table_name.' WHERE user_id = "'.$freelancerid.'"');
return $query->result();
}
Then my controller looks like this
$data['positions'] = $this->freelancer_roles->get_roles_by_id($freelancer_id);
As that is bring back an array i cant use a foreach statement to check the radio button id's that are returned in the positions array.
Could someone help me to figure this out.
Cheers,
I think I understand your question and it seems a fairly simple thing you are trying to do. If
You should have your model only return an array of the names of the checkboxes saved by the user in the following format: array("checkbox1", "checkbox2", "checkbox3") then in your output
you can simply use the native php function in_array()
for example:
$output .= '<div class="row">';
$output .= ' <input name="_'.$row->key.'" type="radio" id="'.$row->key.'" class="radio"';
if(in_array($row->name, $data['positions']) { $output .= ' checked '; }
$output . = '/>';
$output .= ' <label for="'.$row->key.'" style="text-transform: lowercase;">'.$row->name.'</label>';
$output .= '</div>';
As a side note, you have the following code:
if($i > 0){
$i = 0;
}
if($i == 0) {
$output .= "<div class='box'>";
}
If you follow the logic in that code you will see that $i will always equal 0 for the second if statement, making both if statements redundant.

Resources