Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Is there any code to Auto generate sitemaps in wordpress custom theme.
I have a blog site built in wordpress and have manually created sitemap for each page.
I am not using plugins because
1.I do not require all pages to be listed in sitemap
2.Additional Plugins will increase load time in my site
Now i need a simple method(code) to generate a sitemap of my blogs.
Here is a simple code which you need to add in your theme function file to generate sitemap when each blog is posted.Please refer this blog
This can also be used in any custom plugins.
add_action("publish_post", "eg_create_sitemap");
add_action( "save_post", "eg_create_sitemap" );
function eg_create_sitemap() {
$postsForSitemap = get_posts( array(
'numberposts' => -1,
'orderby' => 'modified',
'post_type' => array( 'post'),
'order' => 'DESC'
) );
$sitemap = '<?xml version="1.0" encoding="UTF-8"?>';
$sitemap .= "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
foreach( $postsForSitemap as $post ) {
setup_postdata( $post );
$postdate = explode( " ", $post->post_modified );
$sitemap .= "\t" . '<url>' . "\n" .
"\t\t" . '<loc>' . get_permalink( $post->ID ) . '</loc>' .
"\n\t\t" . '<lastmod>' . $postdate[0] . '</lastmod>' .
"\n\t\t" . '<changefreq>monthly</changefreq>' .
"\n\t" . '</url>' . "\n";
}
$sitemap .= '</urlset>';
$fp = fopen( ABSPATH . "sitemap_blog.xml", 'w' );
fwrite( $fp, $sitemap );
fclose( $fp );
}
Related
I would like to get the order details using observer ,
Once i get the order it will sent order details to my test email , but i can not able to get the order details.
please check the code which i tried to get the order details, Can someone let me know how can i get the order details , thanks.
public function postdata($observer) {
$to = 'testmail#gmail.com';
$subject = 'Mail after Sale order place.';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = 'This is my first Magento Observer After Sale order place';
mail($to, $subject, $message, $headers);
$order = $observer->getEvent()->getOrder();
$order_message = $order;
foreach($order as $ok => $ov) {
$order_message .= $ok. " => " .$ov;
}
mail($to, $subject, $message, $headers);
}
}
You can configure Magento to send you a copy of the order confirmation email that gets sent to the customer. If that is sufficient for your needs, this previously answered question will do the trick.
Use sale_order_save_after event to get the order details after place the order.
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.';
}
When I add images to my email, SwiftMailer notifies that it has been sent, but I do not see it in my inbox, and there are not PHP errors neither.
On the other hand, without the images, the HTML, is successfully sent to my inbox. When I strip tags from the HTML message and send, I get the images alone in my inbox.
I have been dealing with this for about 3 days, and researching for a workable solution to no avail. Any help will be appreciated.
Thanks.
require_once 'Swift_Mailer/swift_required.php';
$message = Swift_Message::newInstance();
$img1 = $mail->embed( Swift_Image::fromPath( IMGFILEPATH . "img1.png" ));
$img2 = $mail->embed( Swift_Image::fromPath( IMGFILEPATH . "img2.png" ));
$subject = "To Whom It May Concern.";
$msg = "<body><div style='background:#002211; padding:10px;'><a href='" . $url . "' target='_BLANK'><img src='" . $img1 . "' id='image1' class='BORDERZERO' alt='GC' /> <img src='" . $img2 . "' id='image2' class='BORDERZERO' alt='General Collections Box.' /></a></div>";
$msg .= "<hr style='color:#555555; height:1px; background:#777777; vertical- align:top;'/><div style='padding:10px; background:#777777; color:#000000;'>";
$msg .= "<span>Hello,<br /><br />We would like to say thank you for donating to our collections box.<br /><br />The General Collections Box.<br />
$msg .= "<hr style='color:#555555; height:2px;' />";
$msg .= "If you believe that this message was sent to you in error or that you are not the intended recipient, please simply discard and disregard it. Thank you for your cooperation. - GBC.<br /></span></div></body>";
$message->setSubject( $subject )->setFrom( array( $sender => $sender_name ))
->setTo( array( $recipients ))->setBody( $html, "text/html" )
->addPart( strip_tags( $html ), "text/plain" )->setPriority( 2 )
->setReadReceiptTo( "$sender" );
if( !MMCS_Service::getSwiftMailer()->send( $mail, $failures )){
var_dump( $failures );
exit( 0 );
}
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.
Magento Admin has a store select drop down list of all the stores.
I have added an addititional "SELECT ALL STORES" value to allow me to know when a user wishes to carry out a task on all stores.
I based this customisation on enterprise magento version 1.9 although I think the version is quite irrelevant since my question is quite generic to magento I think.
How do I stop my "SELECT ALL STORES" from being selected by default in the search ?
/index.php/admin/admin/urlrewrite/index
The store list select form is built here:
app\code\core\Adminhtml\Block\Widget\Grid\Column\Filter\Store.php
Once I found that, I could override it to the local code pool and make the modifications I needed.
public function getHtml()
{
$storeModel = Mage::getSingleton('adminhtml/system_store');
/* #var $storeModel Mage_Adminhtml_Model_System_Store */
$websiteCollection = $storeModel->getWebsiteCollection();
$groupCollection = $storeModel->getGroupCollection();
$storeCollection = $storeModel->getStoreCollection();
$allShow = $this->getColumn()->getStoreAll();
$html = '<select name="' . $this->_getHtmlName() . '" ' . $this->getColumn()->getValidateClass() . '>';
$value = $this->getColumn()->getValue();
//if ($allShow) {
$html .= '<option value=""' . (**$value == 0** ? ' selected="selected"' : '') . '>' . Mage::helper('adminhtml')->__('All Store Views') . '</option>';
//} else {
// $html .= '<option value=""' . (!$value ? ' selected="selected"' : '') . '></option>';
//}