Get position side of first line - location

Tryng get code position side of first code!
$fetchcategory = $results['category'];
$string = array ( '/\b(.*?)\b/i' );
$replace = array ( '$1' );
$category = preg_replace($string, $replace, $fetchcategory);
echo '<p class="news_cat" /><p class="news_date"><img title="News category!" dir="ltr" src="img/category.png" style="width: 13px; height: 13px;" /> Category: '.$category.'</p>';
echo '</p>';
This is code what i want show side to the first one what is
echo '<p class="news_date"><img title="Date added!" dir="ltr" src="img/info_date.png" style="width: 13px; height: 13px;" /> ';
$timestamp = $results['timestamp'];
$date = strtotime($timestamp);
echo $postdate = date("d.m.Y",$date);

You have to edit your PHP so you echo out both the information for the date and category at the same time. Inside the paragraph with class news_date, lets have a look at the code for the category
echo '<p class="news_cat" />'.
'<p class="news_date">'.
'<img title="News category!" dir="ltr" src="img/category.png" style="width: 13px; height: 13px;" />'.
'Category: '.$category.
'</p>';
And the code for the date
$timestamp = $results['timestamp'];
$date = strtotime($timestamp);
echo '<p class="news_date">'.
'<img title="Date added!" dir="ltr" src="img/info_date.png" style="width: 13px; height: 13px;" />';
echo $postdate = date("d.m.Y",$date);
// Missing end thag for paragraph!
echo '</p>';
if we merge those together we get something like this:
$timestamp = $results['timestamp'];
$date = strtotime($timestamp);
echo '<p class="news_date">'.
'<img title="Date added!" dir="ltr" src="img/info_date.png" style="width: 13px; height: 13px;" />';
echo $postdate = date("d.m.Y",$date);
echo '<img title="News category!" dir="ltr" src="img/category.png" style="width: 13px; height: 13px;" />'.
'Category: '.$category.
// Missing end tag for paragraph!
'</p>';
And then the output is this:
<p class="news_date">
<img dir="ltr" src="img/info_date.png" style="width: 13px; height: 13px;" title="Date added!">
20.08.2015
<img class="" dir="ltr" src="img/category.png" style="width: 13px; height: 13px;" title="News category!">
Category:
Film
</p>
And on the page you will have it result in looking like this:
instead of this:
As you can see, by simply dividing the php and output into several lines for debugging it becomes much clearer. We even found ourself a paragraph with no ending tag, but fixed it.

Related

Magento core/email_template_mailer not send mail for a custom module

I have create a email template for a custom module.
For that case it have using core/email_template_mailer ( Mage::getModel('core/email_template_mailer');) and also it has html template .But it is not working;
Here define template html in config.xml
<template>
<email>
<vendor_create_account_email_template translate="label" module="vendor">
<label>New account</label>
<file>vendor_account_new.html</file>
<type>html</type>
</vendor_create_account_email_template>
</email>
</template>
favorite
i have create a email template for a custom module.
For that case it have using core/email_template_mailer ( Mage::getModel('core/email_template_mailer');) and also it has html template .But it is not working;
Here define template html in config.xml
New account
vendor_account_new.html
html
And Mail send code is
$vednor=Mage::getModel('vendor/vendor')->load(66);
/** #var $mailer Mage_Core_Model_Email_Template_Mailer */
$mailer = Mage::getModel('core/email_template_mailer');
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addTo($vednor->getEmail(), $vednor->getName());
$mailer->addEmailInfo($emailInfo);
// Set all required params and send emails
$mailer->setSender('amit#gmail.com');
$mailer->setStoreId(1);
$mailer->setTemplateId('vendor_create_account_email_template');
$mailer->setTemplateParams(array('vendor' => $vednor));
$mailer->send();
And code in vendor_account_new.html is
<!--#subject Welcome, {{var vendor.name}}! #-->
<!--#vars
{"store url=\"\"":"Store Url",
"var logo_url":"Email Logo Image Url",
"htmlescape var=vendor.name":"Customer Name",
"store url=\"customer/account/\"":"Customer Account Url",
"var vendor.email":"Customer Email",
"htmlescape var=$customer.password":"Customer Password"}
#-->
<!--#styles
body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
#-->
<body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
<tr>
<td align="center" valign="top" style="padding:20px 0 20px 0">
<!-- [ header starts here] -->
<table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
<tr>
<td valign="top">
<img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></td>
</tr>
<!-- [ middle starts here] -->
<tr>
<td valign="top">
<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{htmlescape var=$vendor.name}},</h1>
<p style="font-size:12px; line-height:16px; margin:0 0 16px 0;">Welcome to {{var store.getFrontendName()}}. To log in when visiting our site just click Login or My Account at the top of every page, and then enter your e-mail address and password.</p>
<p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin:0; padding:13px 18px; background:#f9f9f9;">
Use the following values when prompted to log in:<br/>
<strong>E-mail</strong>: {{var vendor.email}}<br/>
<strong>Password</strong>: {{htmlescape var=$vendor.password}}<p>
<p style="font-size:12px; line-height:16px; margin:0 0 8px 0;">When you log in to your account, you will be able to do the following:</p>
<ul style="font-size:12px; line-height:16px; margin:0 0 16px 0; padding:0;">
<li style="list-style:none inside; padding:0 0 0 10px;">– Proceed through checkout faster when making a purchase</li>
<li style="list-style:none inside; padding:0 0 0 10px;">– Check the status of orders</li>
<li style="list-style:none inside; padding:0 0 0 10px;">– View past orders</li>
<li style="list-style:none inside; padding:0 0 0 10px;">– Make changes to your account information</li>
<li style="list-style:none inside; padding:0 0 0 10px;">– Change your password</li>
<li style="list-style:none inside; padding:0 0 0 10px;">– Store alternative addresses (for shipping to multiple family members and friends!)</li>
</ul>
<p style="font-size:12px; line-height:16px; margin:0;">If you have any questions about your account or any other matter, please feel free to contact us at {{config path='trans_email/ident_support/email'}} or by phone at {{config path='general/store_information/phone'}}.</p>
</td>
</tr>
<tr>
<td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
Can any one tell me,what are the issue...
use this..
for config.xml
<template>
<email>
<custom_payment module="paymentlink">
<label>Payment Link</label>
<file>custom_payment.html</file> <!-- this specifies the path where the custom template is located -->
<type>html</type>
</custom_payment>
</email>
</template>
for controller
try{
//load the custom template to the email
$emailTemplate = Mage::getModel('core/email_template')->loadDefault('custom_payment');
// it depends on the template variables
$emailTemplateVariables = array();
$emailTemplateVariables['order_id'] = $data['order'];
$emailTemplateVariables['logo_url'] = $logo;
$emailTemplateVariables['customer_name'] = $firstname;
$emailTemplateVariables['customer_info'] = $firstname.' '.$lastname;
$emailTemplateVariables['shipment_url'] = $data['link'];
$emailTemplateVariables['store_name'] = Mage::app()->getStore()->getName();
$emailTemplate->setSenderName($senderName);
$emailTemplate->setSenderEmail($senderEmail);
$emailTemplate->setType('html');
$emailTemplate->setTemplateSubject($firstname.' you forgot to choose shipping options for your product');
$emailTemplate->send($data['email'], $firstname . $lastname, $emailTemplateVariables);
$linker = mysql_real_escape_string(base64_encode($data['link'])); //print_r($linker);exit;
$model = Mage::getModel('paymentlink/paymentlink')
->setRelatedOrderid($data['order'])
->setCustEmail($data['email'])
->setPrice($data['price'])
->setReceived(0)
->setLink($linker)
->setLinkId($data['key'])
->save();
Mage::getSingleton('adminhtml/session')->addSuccess("Link has been Generated successfully & Email has been sent ! </br>".$data['link']."");
}
catch (Exception $e) {
$errorMessage = $e->getMessage();
Mage::getSingleton('adminhtml/session')->addError("We cannot send generated link . There must be some error occurs.");
return $errorMessage;
}
After a long fight with code , i have got it solution.Main, issue was the code format and it variable system format.
Here the code And steps:
Step1:Get current store id.
$storeId=Mage::app()->getStore()->getId();
Step2: Sender() parameters should be in array format array('email'=>(string) $senderemail,'name'=> (string)'$sendername);
....
Full code is
$storeId=Mage::app()->getStore()->getId();
$Vendor=Mage::getModel('vendor/vendor')->load(57);
/** #var $mailer Mage_Core_Model_Email_Template_Mailer */
$mailer = Mage::getModel('core/email_template_mailer');
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addTo((string)$Vendor->getEmail(),(string) $Vendor->getName());
$mailer->addEmailInfo($emailInfo);
// Set all required params and send emails
$mailer->setSender(array('email'=>(string) 'dev.amitbera#gmail.com','name'=> (string)'Bal ta'));
$mailer->setStoreId($storeId);
$mailer->setTemplateId((string) 'vendor_account_create_template');
$mailer->setTemplateParams(array('vendor'=>$Vendor));
$mailer->send();

How to make a rounded image as a selected area of a link in css/php?

I have some rounded images (png) and I would like to make them work as a clickable area for some links. I am trying to do that in the css:
a { color: #234c9e; text-decoration: none; line-height: inherit; display: block; border: 3px dashed #000;}
but it works for squared images only. Is it simple or do i need to seek for javascript for this?
It doesn't seem like this can be done with just CSS, but I could be wrong...
HTML supports it.
<img src="/images/usemap.gif" alt="usemap" border="0"
usemap="#tutorials"/>
<map name="tutorials">
<area shape="circle"
coords="50,50,50"
alt="PHP Tutorial"
href="/php/index.htm"
target="_blank" />
</map>
Reference
Also seems possible with php:
<map id="schemaMap" name="schemaMap">
<? for ($i=0;$i<3;$i++):?>
<area shape="<?php echo $shape ?>"
coords="<?php echo $coords[$i] ?>"
<? if ($curretAction == $action [$i]):?>
onclick ="return false;"
<? else: ?>
href ="<?php echo $links[$i] ?>"
<? endif; ?>
alt ="<?php echo $this->translate($alt[$i]); ?>"
/>
<? endfor;?>
</map>
Reference
Also seems possible with jQuery:
$(document).ready(function() {
if($('#location-map')) {
$('#location-map area').each(function() {
var id = $(this).attr('id');
$(this).mouseover(function() {
$('#overlay'+id).show();
});
$(this).mouseout(function() {
var id = $(this).attr('id');
$('#overlay'+id).hide();
});
});
}
});
Reference here.

Dompdf make a blank page inside the generated pdf Document

i have tried creating pdf files with dynamic content (generated with db data)
DomPdf was perfectly working with it.
but when i add some addtional section it breaks the content in the middle of div blocks.
So i added page-break-inside: avoid; then that problem solved.
now it makes a blank page after that div element in the pdf document !
Any Solutions? Thanks in advance !
Here is the Code within the php :
if(mysql_num_rows($get_options_query) > 0){// we have options available
$color2 = 'f9ebd4';
$quote_items .= '<div style="page-break-inside: avoid; width: 760px; height: auto;"><div style="width: 760px; height: auto; background-color: #f19221;padding:5px; ">Options:</div>';
while($get_options = mysql_fetch_array($get_options_query)){
$prod_opt_col_images='';
$all_prod_opt_col=$db->get_results("SELECT colour_name, colour_image
FROM prod_variations
JOIN prod_colours ON prod_variations.product_colour = prod_colours.colour_name
WHERE prod_variations.product_id ='".$item['product_id']."'");
if(count($all_prod_opt_col)>0){
$prod_opt_col_images='<br />'.'Available in:<br />';
foreach($all_prod_opt_col as $row_prod_opt_col ){
$prod_opt_col_images.='<img src="'.URL.'/images/colours/mat/'.$row_prod_opt_col->colour_image.'" width="25" height="25" alt="'.$row_prod_opt_col->colour_name.'" "/> ';
}
}
if($prod_opt_col_images!=''){
$prod_opt_col_images.='<br />';
}
$quote_items .= '<div class="options" style="background-color: #'.$color2.';">
<div class="divCell1"> '.$get_options['qp_prod_qty'].'</div>
<div class="divCell2"> '.str_replace("<br>","<br />",$get_options['qp_prod_name']).'<br />'.str_replace("<br>","<br />",$get_options['qp_prod_desc']).$prod_opt_col_images.'</div>
<div class="divCell3"> <img src="'.URL.'/images/products/'.$get_options['qp_prod_image'].'" width="75" height="75" alt="Quote Product" /></div>
<div class="divCell4"> $'.number_format($get_options['qp_prod_price'],2,'.',',').'</div>
<div class="divCell5"> </div>
</div></div>';
}
}

WordPress Featured Image Not In Div

I have a featured image for a Custom Post Type that I am trying to lay out in a div. For some reason the image is on the page but outside the div. This is my first time working with featured images and custom post types. What am I missing that is causing the image to appear on the page before the div even starts?
if ($loop->have_posts()) {
$output = '<div class="stories">';
while($loop->have_posts()){
$loop->the_post();
$meta = get_post_meta(get_the_id());
$output .= '
<div class="story" style="float: left; display: block; border: 1px solid #CCC;">
<a href="' . get_permalink() . '">
' . get_the_title() . '</a>
' . the_post_thumbnail("medium") . '
' . get_the_excerpt() . '
</div>
';
}
$output .= "</div>";
} else {
$output = 'No Stories Added Yet.';
}
return $output;
When I view the HTML output this is what is rendered:
<div class="row-fluid ">
<img class="attachment-medium wp-post-image" width="300" height="195" alt="13755721_m" src="http://code2media.net/wp-content/uploads/2013/04/13755721_m-300x195.jpg">
<img class="attachment-medium wp-post-image" width="300" height="240" alt="African-Boy" src="http://code2media.net/wp-content/uploads/2013/05/Snotty-African-Boy-300x240.jpg">
<div class="stories">
<div class="story" style="flost: left; display: block; border: 1px solid #CCC;">
Story 2
Test Content
</div>
<div class="story" style="flost: left; display: block; border: 1px solid #CCC;">
Test Content
</div>
the_post_thumbnail("medium") is echoing the image thumbnail immediately when it is called, outside your other HTML as it is still being constructed, and appending an empty return value to your string. If you want the method to return the result to append to your string (you do), then you need to use get_the_post_thumbnail($post->ID, "medium")
Generally speaking, WordPress methods that start with the_ will echo the result, and methods that start with get_ will return the value.
the_post_thumbnail("medium") will return with img tag. you can get just featured image src and use as as want.
Take a look the this

Joomla 1.5. How to add Like / Dislike button on videos / images?

I'm useing Joomla 1.5 AllVideoShare (Version 1.2.4) extension.
QUESTION PART 1
I want to ask you how to make like button on videos thumbs/images? For example if user likes video clip or image he can click like button and It counts how many users like It. It can be simple like button or facebook button if possible. Also maybe possible to make Like / Dislike buttons (If user don't like this video/image he can dislike It)
Example where I want to place:
http://img689.imageshack.us/img689/268/likecp.png
This is my part of code where videos are publishing:
<?php if ($this->params->get('show_'.$header, 1)) : ?>
<h2> <?php echo $this->escape($this->params->get($header)); ?> </h2>
<?php endif; ?>
<div id="avs_gallery2<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>">
<?php
if(!count($videos)) echo JText::_('ITEM_NOT_FOUND');
for ($i=0, $n=count($videos); $i < $n; $i++) {
$clear = '';
if($column >= $this->cols) {
$clear = '<div style="clear:both;"></div>';
$column = 0;
$row++;
}
$column++;
echo $clear;
?>
<span class="name"><?php echo $categories[$i]->name; ?></span>
<div id="testas" class="avs_thumb" style="width:190px;" onclick='javascript:location.href="<?php echo JRoute::_($link.$videos[$i]->slug.$qs); ?>"'>
<img class="arrow" src="<?php echo JURI::root(); ?>components/com_allvideoshare/assets/play.gif" border="0" style="margin-left:80px; margin-top:47px;" />
<img class="image" src="<?php echo $videos[$i]->thumb; ?>" width="190; " height="120;" title="<?php echo JText::_('CLICK_TO_VIEW') . ' : ' . $videos[$i]->title; ?>" border="0" />
<span class="title"><FONT COLOR="#000000"><?php echo $videos[$i]->title; ?></font></span>
<span class="views"><FONT COLOR="#000000"><?php echo JText::_('Peržiūros'); ?> : <strong><?php echo $videos[$i]->views*2+1; ?></strong></font></span>
<div class="avs_category_label"><?php echo JText::_('Kategorija'); ?> : <strong><?php echo $videos[$i]->category; ?></strong></div>
</div>
<?php } ?>
QUESTION PART 2
After I add Like / Dislike buttons will be possible to sort them by "Most popular" (Which video have most likes) or there are so hard work?
Example: http://www.anekdotai.lt/
QUESTION PART 3
In the same place as Like / Dislike button I want to put Facebook share button. I have script which works, but I can't succesfully add It to this place.
FB Share script:
<?php
defined('_JEXEC') or die('Restricted access');
$linkTxt = $params->get( 'linkTxt', '' );
$linkColor = $params->get( 'linkColor', '' );
$linkHColor = $params->get( 'linkHColor', '' );
$theUrl = $params->get( 'theUrl', '1' );
$wholeUrl = "location.href.substring(0,location.href.lastIndexOf('/'))";
$currentUrl = "location.href";
?>
<script>function fbs_click() {u=<?php if($params->get('theUrl', 1))
{
echo $currentUrl;
}
else{
echo $wholeUrl;
} ?>;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_button { display: -moz-inline-block; display:inline-block; padding:1px 1px 1px 20px; height:17px; color:#<?php echo $linkColor ?>; background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat left; } html .fb_share_button:hover { color:#<?php echo $linkHColor ?>; background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat left; text-decoration:none; } </style> <a rel="nofollow" href="http://www.facebook.com/share.php?u=<url>" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;"><?php echo $linkTxt; ?></a>
If I put It to Video publishing code I get error:
Fatal error: Call to a member function get() on a non-object in ..../juokoera.lt/public_html/components/com_allvideoshare/views/videos/tmpl/default.php on line 26
Thank you for answers.
Try adding the following code which will define the $params variable:
$params = JComponentHelper::getParams( 'com_yourcomponent' );

Resources