I do not understand the functioning of the css codeigniter - codeigniter

I'm new to CodeIgniter PHP programmer, and am facing a problem of setting css, divs achieve include the templates created in the views folder as header, content and footer, css settings functioned normally, but there is a resource that is in CodeIgniter get the template to be in the views folder and you deploy the css settings, and this feature did not work. I'll put the lines of code to give you an idea.
file /controllers/home
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class Home extends CI_Controller{
public function __construct() {
parent::__construct();
}
public function index(){
$this->load->view('html_header');
$this->load->view('cabecalho');
$this->load->view('menu_categorias');
$this->load->view('conteudo');
$this->load->view('rodape');
$this->load->view('html_footer');
}
}
file html_header.php
<?php echo doctype('xhtml1-trans'); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Meu website de receitas</title>
<?php
$meta = array(
array('name' => 'robots', 'content' => 'no-cache'),
array('name' => 'description', 'content' => 'Meu website de receitas'),
array('name' => 'keywords', 'content' => 'Receitas, doces, salgados, sobremesas, massas'),
array('name' => 'robots', 'content' => 'no-cache'),
array('name' => 'Content-type', 'content' => 'text/html; charset=utf-8', 'type' => 'equiv')
);
echo meta($meta);
echo link_tag('assets/imgs/fork.ico', 'shortcut icon', 'image/ico');
echo link_tag('assets/css/teste.css');
?>
</head>
<body>
file cabeçalho.php
<div id="tres"></div>
file conteúdo.php
<div id="dois"></div>
file html_footer.php
<div id="quatro"></div>
</body>
</html>
file teste.css
#tres{
width: 200px;
left: 200px;
float: right;
border: solid 5px #000;
}
#dois{
width: 200px;
left: 200px;
float: right;
border: solid 5px #003399;
}
#cabecalho{
width: 200px;
left: 200px;
float: right;
border: solid 5px #333;
}
what not working in css and settings that were placed to # header.
I would like to know how to put to work.

Try to use this sintax:
$linkCss = array(
'href' => 'assets/css/teste.css',
'rel' => 'stylesheet',
'type' => 'text/css',
'media' => 'screen'
);
echo link_tag($linkCss );
And did you load HTML helper?
$this->load->helper('html');

Related

Laravel 5.4 mail markdown 2 button inline

I would like to know how to place the button next to each other.
Now it is on a separate line.
#component('mail::message')
Dear {{$vendor_name}}
Product {{$product_id}} : {{$product_name}} price id : {{$price_id}} will expire on {{$date_expire}}.
Please renew price.
#component('mail::button', ['url' => 'http://phuketjettour.com/', 'color' => 'green'])
Phuket Jet Tour
#endcomponent
#component('mail::button', ['url' => 'http://phuketjettour.com/s/vendors'])
Vendor submission
#endcomponent
Thanks,<br>
Phuket Jet Tour
#endcomponent
Dynamic number of inline buttons
For me the following worked to create 2, 3, 4 (dynamic number) of buttons inline in Laravel markdown mails:
1) Add a new directory for your custom component
First lets extend the mail configuration to include our new directory for components:
config/mail.php
<?php
// ...
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
resource_path('views/emails/components') // <-- This line was added
],
],
2) Create the new component for inline buttons
You need to create both, the HTML and the text version of the component. Otherwise you will get a InvalidArgumentException "View $name not found":
www/resources/views/emails/components/html/buttons.blade.php
This is the HTML file:
<table class="action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0" role="presentation">
#if(null !== ($headline ?? null))
<tr><td><h2 style="text-align: center;">{{ $headline }}</h2></td></tr>
#endif
<tr>
<td>
#foreach($buttons as $button)
{!! $button['slot'] !!}
#endforeach
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
www/resources/views/emails/components/text/buttons.blade.php
This is the text file
#if(null !== ($headline ?? null))
{{ $headline }}
------------------------------
#endif
#foreach($buttons as $button)
{!! $button['slot'] !!}: {{ $button['url'] }}
#endforeach
3) Include the new component in your mails:
Now you can just include the component in your markdown emails like so:
Example with 2 inline buttons and a headline:
#component('mail::buttons', [
'headline' => 'Share link',
'buttons' => [
[
'url' => 'https://wa.me/?text=' . urlencode('Whatsapp text'),
'slot' => 'WhatsApp',
],[
'url' => 'https://t.me/share/url?text=' . urlencode('telegram text'),
'slot' => 'Telegram',
]
]
])
#endcomponent
Example with 3 inline buttons without a headline:
#component('mail::buttons', [
'buttons' => [
[
'url' => 'https://wa.me/?text=' . urlencode('Whatsapp text'),
'slot' => 'WhatsApp',
],[
'url' => 'https://t.me/share/url?text=' . urlencode('telegram text'),
'slot' => 'Telegram',
],[
'url' => 'https://twitter.com/intent/tweet?text=' . urlencode('Twitter text'),
'slot' => 'Twitter',
]
]
])
#endcomponent
Example with 3 inline buttons with different colours:
#component('mail::buttons', [
'buttons' => [
[
'url' => 'https://wa.me/?text=' . urlencode('Whatsapp text'),
'slot' => 'WhatsApp',
'color' => 'blue' // This is the default
],[
'url' => 'https://t.me/share/url?text=' . urlencode('telegram text'),
'slot' => 'Telegram',
'color' => 'green'
],[
'url' => 'https://twitter.com/intent/tweet?text=' . urlencode('Twitter text'),
'slot' => 'Twitter',
'color' => 'red'
]
]
])
#endcomponent
I have done it like this, ofcourse the css should be in a separated file
<style>
.email-row {
}
.email-col-2 {
width: 49%;
display: inline-block;
}
</style>
#component('mail::message')
<div class="email-row">
<div class="email-col-2">
#component('mail::button', ['url' => '453634', 'color' => 'light'])
btn1
#endcomponent
</div>
<div class="email-col-2">
#component('mail::button', ['url' => '123', 'color' => 'green'])
bnt2
#endcomponent
</div>
</div>
#endcomponent
When passing a variable to a blade template, use a single quote ( ' ) instead of a double quote ( " ).
$btn_style = " color: #FFF; border: 1px solid #FEFEFE; padding: 5px 30px;";
$buttons = '<span style="text-align: center; width: 100%; display: inline-block;">
Accept
Decline
</span>';
To render this code:
Edit your App\Mail
$this
->subject('Subject')
->markdown('emails.tempalte')
->with([
'buttons' => $buttons,
]);
Blade Template view\emails:
{!! $buttons !!}
Hope this helps.
you can put it in one <div>
For example:
<div class = "row>
your buttons here
</div>
If it doesn't help please share your code
Try this:
<span style="display: inline;">
#component('mail::button', ['url' => 'http://phuketjettour.com/', 'color' => 'green'])
Phuket Jet Tour
#endcomponent
#component('mail::button', ['url' => 'http://phuketjettour.com/s/vendors'])
Vendor submission
#endcomponent
</span>
It's just a work around. I've inspect the email from a laravel project.
try this in place of your component for button :
Phuket Jet Tour
SAMPLE !
it inlines your button. then just adjust other element. If you want to put the button on the markdown then you do like:
On your markdown:
$button1= " Phuket Jet Tour";
$button2 = "SAMPLE !";
$emailMarkdown = $this->markdown('your_email_template')
->subject('your_subject)
//you will define here the variables you need to pass in the template
->with([
'emailBody' => $emailBody,
'button_first' => $button1,
'button_second' => $button2,
]);
return $emailMarkdown;
then on the email template:
#component('mail::message')
Dear {{$vendor_name}}
Product {{$product_id}} : {{$product_name}} price id : {{$price_id}} will expire on {{$date_expire}}.
Please renew price.
{!!$button_first!!} {!!$button_second!!}
#endcomponent
To fix the issue, just place this code in email blade file:
<div style="text-align: center">
Cancel
Reschedule
Confirm
</div>

Insertion code does not work in 1.7 which was working in 1.6

I have a Prestashop 1.6 module which has in one point prepares a PDF with barcodes.
The same module I upgraded to 1.7 but now PDF generates without the barcode. I did not change any thing in the template nor controller but bar code does not appear.
I followed this link to prepare bar codes for 1.6 version.
Following is my controller code where bar code prepared.
// Initiat PDF class
$pdf = new PDFGenerator((bool)Configuration::get('PS_PDF_USE_CACHE'));
// Prepare barcode
$barcode_params = $pdf->serializeTCPDFtagParameters(array(
'123456789',
'C39',
'',
'',
50,
20,
0.2,
array(
'position'=>'S',
'border'=>false,
'padding'=>0,
'fgcolor'=>array(0,0,0),
'bgcolor'=>array(255,255,255),
'text'=>true,
'font'=>'Helvetica',
'fontsize'=>8,
'stretchtext'=>0),
'N'));
Following is template code,
<tr>
<td>
<b>Shipper Order Number:</b>
</td>
<td >
<tcpdf method="write1DBarcode" params="{$barcode_params}"/>
</td>
</tr>
Any advice would be greatly appreciated..
Ok, I resolved this issue myself.
But not with this method. for some reason
<tcpd method="write1DBarcode" ... '
seems does not work.
So what I did was I bypassed 'HTMLTemplate..'  class creation and smarty templates all together  for labels and instead used a normal method to output a PDF custom HTML label using native function of TCPD class. 
so here is the codes I used for producing the PDF label.
$style = array(
'position' => 'C',
'align' => 'C',
'stretch' => false,
'fitwidth' => true,
'cellfitalign' => '',
'border' => true,
'hpadding' => 'auto',
'vpadding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => array(255,255,255),
'text' => true,
'font' => 'helvetica',
'fontsize' => 8,
'stretchtext' => 4
);
$html = '<html><head><title></title><style>table { border-collapse:
collapse;font-family:arial;}td {padding: 10px; vertical-align: center;}';
$html .= '</style></head><body>';
foreach ($orders_array as $order)
{
$html = $this->prepare_html_label($order); //  this is where my html
template is prepared with actual values
$pdf->setXY(93,472);
$pdf->Ln(5);
$pdf->write1DBarcode('*'.$order['awb'].'*', 'C128', '', '', '', 18, 0.4,
$style, 'N');
$pdf->Ln(10);
$pdf->writeHTML($html, true, false, true, false, '');
}
$pdf->Output('labels.pdf', 'D');
}
Problem solved.! 
Hope this helps some one.

Pdf is not get attached to my email

I have written a function to send email with attachment.i used PHPMailer class.
Email is send,but the attachment is not getting.
My Controller Code
public function send_mail()
{
$this->load->library('email');
$subject = 'Request For Quotation';
$message = '<p>This message has been sent for testing purposes.</p>';
// Get full html:
$body =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset='.strtolower(config_item('charset')).'" />
<title>'.html_escape($subject).'</title>
<style type="text/css">
body {
font-family: Arial, Verdana, Helvetica, sans-serif;
font-size: 16px;
}
</style>
</head>
<body>
'.$message.'
</body>
//</html>';
$this->load->library('M_pdf');
$this->m_pdf->pdf->setTitle('Request for Quotation');
$html = 'hiiiiiiiiiiiiiiiiiiiiiiiiiiiiii';
$this->m_pdf->pdf->WriteHTML($html);
$content=$this->m_pdf->pdf->Output('RFQ.pdf',"S");
$result = $this->email->from('mm#jiklink.com')->to('jk#gmail.com')->subject($subject)->message($body)->attach($content, '', 'base64', '')->send();
var_dump($result); // echo '<br />'; echo $this->email->print_debugger(); exit;
}
use this code..............
$pdfFilePath = "PDF/RFQ.pdf";
$html='hiiiiiiiiiiiiiii';
//load mPDF library
$this->load->library('m_pdf');
//generate the PDF from the given html
$this->m_pdf->pdf->WriteHTML($html);
//download it.
ob_clean();
$this->m_pdf->pdf->Output($pdfFilePath,'F');
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'Email',
'smtp_pass' => 'Password',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->helper('path');
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('Email');
$this->email->to('email');
$this->email->subject('Subject');
$this->email->attach($pdfFilePath);
$this->email->send();

Add image to button Laravel 5

Hi my submit button is like this:
{!! Form::open([
'id' => 'form-id',
'method' => 'delete',
'action' => ['ToDoListController#delete', $task->id],
]) !!}
{!! Form::submit('Delete', [
'id' => 'my-id',
'name' => 'bt_add',
'image' => '../../images/delete.jpg',
]) !!}
{!! Form::close() !!}
I want to add image to my button but don't know how. Please help me.
Why not use a button?
<button type="submit" id="my-id" name="btn_add"><img src=""></button>
You can add a css class to your button and then define the image to be used in that class e.g.
{!! Form::submit('Delete', [
'id' => 'my-id',
'name' => 'bt_add',
'class' => 'bt_add',
]) !!}
In the css...
.bt_add {
background:url(/images/Btn.PNG) no-repeat;
width: 200px;
height: 100px;
border: none;
}
Sorry I haven't tested this (bit of a hurry) but this should give you the effect you want. See other posts on button images e.g. Setting an image button in CSS - image:active

Magento grid column change align to center in number type

When you are using the number type in Magento's grid column:
$this->addColumn('my_number',
array(
'header' =>Mage::helper('bidashboard')->__('My number'),
'index' => 'my_number',
'total' => 'sum',
'align' => 'center',
'type' => 'number',
'sortable' => false,
));
It seems the 'align' has no affect on it. It is because the align hard-coded on the number type renderer:
class Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Number
...
public function renderCss()
{
return parent::renderCss() . ' a-right';
}
...
So how do I change the align in this case?
The a-right class in the default Magento 1.7.0.2 css file:
/skin/frontend/default/default/css/styles.css
in line 77 has
.a-right {
text-align: left !important;
}
so I guess overwriting this css class in your theme's css file will fix this.
Like this:
body.checkout-cart-index .a-right {
text-align: left !important;
}
or this:
body.checkout-cart-index #shopping-cart-table td:nth-child(7) {
text-align: left !important;
}

Resources