Using variable on smarty tag name in Shopware - smarty

I'm trying to use a variable name to create new snippets, something like this:
{s namespace="frontend/detail/config_variant" name=$variant_group}{/s}
But it doesn't work, it just creates a snippet called $variant_group and I want to get the actual name.
I have tried different combinations and none have worked so far. Can this be generated dynamically?
Thanks

This is already mentioned in the official documentation: https://developers.shopware.com/designers-guide/snippets/#using-dynamic-snippets
{$name = "DetailDataHardness"|cat:$sArticle.attr1}
{$namespace = "frontend/detail/data"}
{$sArticle.attr1|snippet:$name:$namespace}

Related

How can I change the execute order for Magmi plugins?

I'm working on importing (on a regular basis) about 6,000 items into Magento using Magmi. I've got nearly everything configured the way I need it, but I have one issue.
I need to concatenate 3 columns from my .csv file to create a "category_ids" column. I'm using the Value Replacer plugin with the following value:
{item.departmentid},{item.classid},{item.subclassid}
This works well, however I need to then map this field to another field using the Generic Mapper plugin. Both functions work individually, however I need the Value Replacer to run BEFORE the Generic Mapper. As best as I can tell, it appears the Generic Mapper runs first. Is there a way I can alter the execute order for these two plugins?
Thanks for the help!
Update for Dweeves:
Doh! I totally overlooked that section while trying to figure this out. Now that I've gone through it, I might need a little more help. Right now I've using just the Value Replacer plugin with the following settings:
Replaced attributes: category_ids
New value for category_ids:
{{ ValueRemapper::use_csv('/var/www/magmi/category_ids.csv')->map({item.departmentid},{item.classid},{item.subclassid}) }}
It doesn't seem to be working as I intended it to, but I'm a systems guy and not a PHP programmer. Any help?
2nd Edit
I got it working by using the Value Replacer function to first concatenate everything into a new "test" column, then using the Value Replacer Value Mapper function to create the category_ids column with the mapped values. Confusing, but it's working well.
You can use the ValueRemapper helper of Value Replacer plugin for this kind of purpose.
See Value Replacer Plugin Documentation (ValueRemapper helper section)
To answer your original question (how to define the order the plugins run in).
From my experience, the plugins are loaded in order of their plugin filename.
For example, if you look at magmi/plugins/base/itemprocessors/importlimiter, you will notice that the filename for the plugin is 01_importlimiter.php.
If you look in the genericmapper plugin folder, you'll notice the plugin filename to be 02_genericmapper.php.
With this being said, 01_importlimiter.php will execute before 02_genericmapper.php.

how to pass parameters to joomla module loaded from article

I had previously added Joomla modules from within Joomla articles this way : {loadmodule mod_name} but this time I need to pass parameters from it.
How can I pass parameters from within the article to a Joomla module?
You'll need to modify or clone the Joomla plugin loadmodule because it doesn't handle parameters other than just a module name. It's not particularly difficult to do if you're proficient in PHP (assuming you don't mind getting your hands dirty with a little bit of Regex work) but I'd suggest cloning it and using it this way:
Copy folder \plugins\content\loadmodule to \plugins\content\Myloadmodule (and all it's files)
Within the new folder, rename loadmodule.php and loadmodule.xml to myloadmodule.php and myloadmodule.xml. These are the files you'll do all the work on.
In both files, replace occurrences of loadmodule with myloadmodule, (Case sensitive)
In myloadmodule.php, start at around line 36 with the Regex that strips out what is in the {loadposition xxx} being processed. You'll need to tinker with this Regex to get the parameters that you want to supply when using {myloadmoduel blah-blah-blah} in your article.
Find the database entry in your table '_extensions' for loadposition and create and identical record for myloadposition. (Unless you want to write and installer)
Finally, you'll need to render the modules with your new parameters - I can't begin to help there because I don't know what modules, or parameter work you'll be doing, but this renderModule documentation will be of assistance.
7.
I think I've covered it all, but this should be enough to get most of it done for you. When you're done, use {myloadposition ...} instead of {loadposition ...}.
I will give more details about the previous answer, to be able to pass parameters to a module with a tag as {loadmodule mod_name,param}
The solution given by GDP works fine: it's easy and quick to rewrite a content plugin (e.g. myloadmodule), following the steps 1 to 5 in the previous answer.
The problem, for me, comes with the steps 6: how to put parameters into the module, and ohow to retrieve de parameters within the module.
Step 7 : how to give parameters to the "render" of a module
In the plugin created (base on the loadmodule), you have to find the lines with the following code :
echo $renderer->render($module, $params);
Before this line, you can put parameters into the $params parameter, but "render" of the module retrieves only params with the key 'params', using a json format.
So, to pass parameters to the render function, you can do something like that :
$param = array('param_name' => 'value'); // param_name = value
$params = array('params' => json_encode($param)); // 'params' (String) should be decoded by the render of the module
echo $renderer->render($module, $params);
Step 8 : How to retrieve the parameter within the module
In the helper of your module, you can retrieve the parameter with $params variable :
$value = $params->get('param_name');
To understand a helper, read this tutorial : http://docs.joomla.org/J3.3:Creating_a_simple_module/Developing_a_Basic_Module
I googled the same issue and found your question. I know its old but my find may help someone else. There are now plugins that allow embedding modules and allowing you to pass parameters to it. My choice is Module Plant.

Codeigniter, uri->segment, str_len

I'm very new to php and mysql. I'm trying to pass the value "part(2)" to my code igniter controller. "part(2)" is one of the name of the data values in my database. After passing it to the uri segment, I extracted it using the command $value = str_replace("%20", " ", $this->uri->segment(5)); . Now when i search my database using the variable $value, it's not displaying the results. I presume the problem is with having using "()". I am wondering if it has anything to do with the data type utl8 vs latin1. My database is configured to use latin1_general_ci. I have tried changing the database field type to utl8_general_ci, but it does not work. Can anyone please help me out here?.
Have you tried var_dump($value) just to see what it contains?
Also, the result from $this->db->last_query(); might be useful to see what you are actually quering your database for. I don't see a reason why you couldn't put perenthesis in your database.
Im pretty sure both utf8 and latin1 are fine.
can you post your controller code?
firstly, if you are passing the value in your uri, do you have () in your permitted uri characters in application/config/config.php?
something like this:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-()';
But I just tried this and my values came out with html entities: part(2) instead..
you can fix this with something like this:
input_value = html_entity_decode($input_value);

Prototype Form.serialize(this) merging with another hash

I'm trying to merge a form hash with another hash using Prototype (1.6.0.3)
This doesn't pass any parameters to the server
Name
but this does
Name
Any ideas on how to fix this? I don't get any javascript errors.
Looks like this is an issue with the old version of the Prototype docs:
That's a documentation issue. Expected
output (from Form.serialize) is a
vanilla JS object, not a hash https://groups.google.com/group/prototype-core/browse_thread/thread/d686de54683b206c?pli=1
UPDATE
You can achieve what you want like this:
Name
This makes use of Object.extend:
Object.extend(Form.serialize(true), {order: 'descend_by_created_by'})

proper way of setting an attribute in Doctrine?

in some tutorials they tell you to set up an attribute like this:
$manager = Doctrine_Manager::getInstance();
Doctrine_Manager::getInstance()->setAttribute(
Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
and in the documentation it shows you this:
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(
Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
i wonder which one i should use? isn't it the latter one? cause how can you set an attribute to a singleton class in the first one? isn't the second one more correct?
Do you even understand the code you're looking at?
The first code is "wrong". First it assigns Doctrine_Manager object $managger, and then this variable is not used.
If you want to do more than one thing on Doctrine_Manager then it's natural to get assign this reference to something that won't mess up your code. If you want to do just one thing there is no need to use extra variable, in other words:
Doctrine_Manger::getInstance()->setAttribte(...);
or
$manager = Doctrine_Manger::getInstance();
$manager->setAttribute(...);
$manager->setAttribute(...);
$manager->doSth();
$manager->blahblahblah();

Resources