Smarty issues with Fckediter - smarty

I'm new to this forum , i hope u do not mind questions even if its stupid.
i m trying to post a value from the fckeditor embedded in smarty template.The value submitted is,
a
b
c
d
however when echo the posted value i get ,
a b c d
which is very irritating because i want the actual value submitted.
No matter whatever i do i only see text with these tags i do not understand if have to do any configuration in smarty or fckeditor or what ?
Please help with this any help will be greatly appreciated.
i will appreciate your help
Mukesh ?

It was just that my framework used was sanitizing all GET,POST requests.
Then removed those function that was causing the function and job done .
function sanitize($data)
{
$data = trim(strip_tags($data, "<a><b><strong><em><i><u><br><h3><h4><h5>"));
return $data;
}

Related

Get first letter of word in statement

I have a statement like "Animal Association" from the database. I want to get its short form. It means, only the first letter of each word like this "AA". In the blade file, I got the whole statement as follows,
<p>{{ $animal->user->club->name}}</p>
So, how can I get a short form of this name?
Thank You!
If you are using MySQL 8+, then a raw select with REGEXP_REPLACE should work here:
$users = DB::table('animals')
->select(DB::raw("SELECT REGEXP_REPLACE(name, '(\\w)\\w+\\s*', '$1')"))
->get();
This very common problem where we ran into, I can provide you a function that will solve your problem. I am sharing two solutions and you can use any of these solutions.
using function
You can use this function in your model and solve your problem.
public function getNameAbbreviate($string){
$abbreviation = "";
$string = ucwords($string);
$words = explode(" ", "$string");
foreach($words as $word){
$abbreviation .= $word[0];
}
return $abbreviation;
}
There is probably no one-line solution, the solution which I provided is readable and understandable.
using regex
This solution is easy to apply and in case you can't make the first method work then go with this.
<p>{{ preg_split("/\s+/", $animal->user->club->name) }}</p>
using regex we can get a direct solution but I personally don't like it or recommend it.

Trying to sum a groupBy value in Laravel 5.5

I have this code suggested to me. I am trying to sum the stock_in_qty and stock_out_qty.
$warehouse1stocks = Warehouse1stocks::select(
"order_item_id",
Warehouse1stocks::raw('SUM(stock_in_qty) as stock_in_qty'),
Warehouse1stocks::raw('SUM(stock_out_qty) as stock_out_qty'))->groupBy('order_item_id')->get();
// dd($warehouse1stocks);
return view("warehouse1.index", compact("warehouse1stocks", $warehouse1stocks));
My problem is this error
I tried to look for an answer from other questions here and I think my code seems ok but why am i still having that error?
what do you think is the problem with my code? thanks in advance!
Instead of writing:
Warehouse1stocks::raw('SUM(stock_in_qty) as stock_in_qty')
write:
DB::raw('SUM(stock_in_qty) as stock_in_qty')
when defining the write expressions
use this one
$warehouse1stocks = Warehouse1stocks::select(
"order_item_id",
\DB::raw('SUM(stock_in_qty) as stock_in_qty'),
\DB::raw('SUM(stock_out_qty) as stock_out_qty'))->groupBy('order_item_id')->get();
// dd($warehouse1stocks);
return view("warehouse1.index", compact("warehouse1stocks", $warehouse1stocks));

Magento registry variables in controller

I have stored a variable in register by Mage::register('captcha', $var); in helper. And in the controller i tried to retrieve the variable by using Mage::registry('captcha'); But i dont getting any values here. Please help me to solve this.
In your helper file create a function like below :
public function getCaptcha(){
$var = 'myValue123';
Mage::register('varun', $var);
return Mage::registry('varun');
}
In your controller function:
$registryValue = Mage::helper('yourModule')->getCaptcha();
echo registryValue ; //prints myValue123
Hope it helps !!!
It's look like syntax is right.
Please first try to set some static value like $var="test"
Mage::register('captcha', $var);
after that got this value in controller.
Mage::registry('captcha');
if you got this value test then i think you have problem with $var in your helper.
Let me know if you have any problem
'captcha' is already in use, so magento never set your data in registry. Change the name, for example 'captcha1'
Mage::register('captcha1', $var);

Magento: different currency for different store view

I have several store views (Germany, Ireland, Switzerland...) all which are supposed to have different currencies.
However, when I set the correct default currency on store view level in the configuration - nothing happens.
I hope someone is familiar with this problem. Thanks!
If anyone could tell me where to find the line in the code which prints out the currency symbol in the product page, it would also help me!
*UPDATE
I found list.phtml in /app/design/frontend/default/THEME/template/catalog/product
there the following line can be found:
<?php echo $this->getPriceHtml($_product, true) ?>
Does anyone know where this function (getPriceHtml) is located?
# Bixi: yes I did.
# Piotr: thank you, unfortunatelly the function:
public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix='')
{
return $this->_getPriceBlock($product->getTypeId())
->setTemplate($this->_getPriceBlockTemplate($product->getTypeId()))
->setProduct($product)
->setDisplayMinimalPrice($displayMinimalPrice)
->setIdSuffix($idSuffix)
->setUseLinkForAsLowAs($this->_useLinkForAsLowAs)
->toHtml();
}
is not helping me in finding the bug. Where is the function which defines which currency is displayed? I am very close to giving up...
This method is in Mage_Catalog_Block_Product_Abstract
You can also check the method convertPrice in Mage_Core_Model_Store. Generally price conversion is handled by Zend_Currency

Codeigniter problem with routes!

I am trying to do this route trick:
$route['cp/roles/:num'] = "cp/roles/index/:num";
but it doesn't work :(
please help me!!
advanced thanks .
According to the documentation on URI Routing:
$route['product/(:num)'] = "catalog/product_lookup_by_id/$1";
“A URL with "product" as the first segment, and a number in the second will be remapped to the "catalog" class and the "product_lookup_by_id" method passing in the match as a variable to the function.”
So, for your particular instance, you would do the following:
$route['cp/roles/(:num)'] = "cp/roles/index/$1";
You could try
$route['cp/roles/:num'] = "cp/roles";
and then instead of passing a variable in your function you use
$this->uri->segment(3);
or the number that correspond to the segment.

Resources