I'm using the bundle of Symfony, Gregwar/CaptchaBundle. Itworks great exept that point: I need to renex the code to make it works, if not i have the message "code does not match".
I'm using it in the regitration form of the bundle FOSUser.
I tried to remove the renew option but it doen't make any change.
This is the code i use in my form:
$builder->add('captcha', 'captcha', array('as_url' => true, 'reload' => true));
Some one has an idea of how to resolve that? Or maybe there is another bundle i can use to do that?
Thank you and hope i was clear.
David
Related
I've recently upgraded a site to Drupal 7.59 with install profile:
Commerce Kickstart (commerce_kickstart-7.x-2.54)
Previously there was a function that had been added to the core which has now been removed because of the upgrade. This shouldn't have been added to the core and I'm not sure why it was. I've added this function back in and its not doing what it did previously so I'm not sure what other changes I would need to make to get it to work.
Here's the function which is found in /profiles/commerce_kickstart/themes/commerce_kickstart_admin/template.php -
function commerce_kickstart_admin_commerce_price_formatted_components($variables) {
// Add the CSS styling to the table.
drupal_add_css(drupal_get_path('module', 'commerce_price') . '/theme/commerce_price.theme.css');
// Build table rows out of the components.
$rows = array();
foreach ($variables['components'] as $name => $component) {
$rows[] = array(
'data' => array(
array(
'data' => $component['title'],
'class' => array('component-title'),
),
array(
'data' => $component['formatted_price'],
'class' => array('component-total'),
),
),
'class' => array(drupal_html_class('component-type-' . $name)),
);
}
if($variables['components']['discount']['price']['amount']){
unset($rows[0]);
unset($rows[2]);
}else{
$rows = array_splice($rows, 2);
}
return theme('table', array('rows' => $rows, 'attributes' => array('class' => array('commerce-price-formatted-components'))));
}
Can anyone give any pointers as to how to get this working? It doesn't appear to even be getting invoked.
Additional info from the comments:
it's a function in the profile?
yes
Was the function added afterwards (as in "Never hack core")?
Yes, looks like it.
Or was it removed by the maintainers?
Doesn't look like this was ever part of any official release
Do you use some version control system like Git?
Yes. This function was added on 14/05/2015 12:18 according to the repo.
Have you checked the profile's release notes and issue queue?
Had a look but don't see anything.
Thanks for adding the extra info!
Well, if this really was custom code than it should never have been added to the profile in the first place. Never ever add custom code to any core or contrib file. As it's going to be deleted as soon as you update. Like it has happened to you.
I guess the most important part of this custom function was drupal_add_css(drupal_get_path('module', 'commerce_price') . '/theme/commerce_price.theme.css'); and that this commerce_price.theme.css maybe also got deleted.
Apart from that it's hard to tell from far and I'm not an expert in the commerce module. So, what I would do now is to narrow down the issue systematically.
Restore your repo to a time in history before this module got updated and get the site running.
Find out what this code is doing exactly, what other functions or flows are involved. Maybe with the help of the Devel module and the mighty dpm() function.
Try to rebuild the custom code from the profile in a custom module.
Then reset the repo to the current state and see if your custom module's code is still firing. If not, debug it to match the updated profile's code.
Apart from that, find the person who added the code and ask them why and what this code is doing. And tell them to never ever again hack core or contrib code :)
Good luck!
I'm crawling a web page that's returning a redirect, so I'd like to add a configuration option into my crawler that that will let me set allow_redirects to false. Looking at the guzzle.readthedocs.org web page in regards to redirects, it says
$response = $client->get('http://github.com', ['allow_redirects' => false]);
echo $response->getStatusCode();
// 301
Since I am using Goutte with Symfony2, these commands are a little different. For example:
$client->getClient()->setDefaultOption('config/curl/'.CURLOPT_SSL_VERIFYHOST, FALSE);
Can anyone help me discover how I can add the guzzle allow_redirects to the configuration? I feel that this will help me to not get page content that I want and not a crawler full of redirect code.
Thanks!
Your question is, how to "translate" ['allow_redirects' => false] into Goutte-syntax?
Well, here's how to set up cURL options in Goutte: https://github.com/FriendsOfPHP/Goutte (search for "Fine-tune cURL options:")
And http://php.net/manual/en/function.curl-setopt.php gives you the name of the option you're looking for: CURLOPT_FOLLOWLOCATION
So putting it all together:
$client->getClient()->setDefaultOption('config/curl/'.CURLOPT_FOLLOWLOCATION, false;
If that's not what you asked for, please edit your question and clarify.
I'm just a little desperate.
I installed the RSS Display extension.
http://typo3.org/extensions/repository/view/rss_display
Everything works fine, but I have just a little understanding problem.
I pull myself with fluid the Author for the current feed.
<feed:item.get value="author"/>
Than i look whats inside.
<f:debug><feed:item.get value="author"/></f:debug>
Thats the result.
SimplePie_Author prototype object
name => 'Name Name' (12 chars)
link => NULL
email => NULL
So what i need it's to get the name of the author.
Unfortunately i am not able to get the value.
I am really new in Fluid, Typo3.
Hopefully someone can help me.
One way to do this, is to create a fluid variable author and assign the author object to it. Then you can access the name using {author.name}.
To create a variable, you could use the ViewHelper <f:alias>, like this:
<f:alias map="{author: '{feed:item.get(value: \'author\')}'}">
{author.name}
</f:alias>
Another way would be to use the extension "vhs", which provides many tools for use with fluid. One of these tools is the ViewHelper <v:variable.set>, which could be used like this:
<v:variable.set name="author" value="{feed:item.get(value: 'author\'}"/>
{author.name}
This has the advantage that you don't need to use the variable within the tags of the ViewHelper.
There are other ways to reach the same goal, without defining variables, but this seems to be the easiest one to me.
I am running into an issues with dump() in Twig.
I am not able to completely dump the values of the object that I am returning to my twig template. My object, as defined below, is built up of a product object, qty key/val, OnOrder key/val and avgUnitCost key/val.
I AM able to use dump(qty), dump(OnOrder), dump(avgUnitCost) and see the values of these.
I AM NOT able to use dump() on product to see the key/val of the product object. All I get is a white page of death.
I have read elsewhere on stack that it is a memory issue in the php.ini file. This does not seem to fix the issue, I set mine 1024M and it still times out and gives me the white screen.
I have also read this guys article on the same issue: http://hectorpinol.com/twig-debug-in-symfony-2/ ... He thinks it is a "bidirectional association problem".
In any case, here is the code that I am using to pass the object and render my twig template...
return $this->render('TestBundle:Event:view.html.twig', array(
'heading' => 'View Product',
'product' => $product,
'qty' => $qty,
'OnOrder' => $OnOrder,
'avgUnitCost' => $avgUnitCost,
));
Here is the guts of my question:
How can one effectively use twig to access the elements of an object, whether it be dump or some other method. I need to be able to see all of the elements in the object so that I can place them on the page as I need.
Thanks so much for your help!!!
Check LadybugBundle. You can dump everything.
Try adding a break point in twig_var_dump:
/vendor/twig/twig/lib/Twig/Extension/Debug.php (at the bottom)
Then you can use the functionality of your debugger...
Look at this answer: https://stackoverflow.com/a/29302069/4102223
It is my approach to solve this problem, only few lines must to be changed in one place (it is easier because no need to include new bundles and read its documentation).
EDIT: Seems like my "array-crawling" skills were not enough, thanks for the suggestions.
Moreover, I found out that I was checking the $discounttype condition with a plain "=" instead of a double "==". I guess banging your head on the same block of code for 3 hours makes you dumb and miss the most obvious errors.
First thing first, I'm on Drupal 6.
I have created a form with the following markup:
$form["cart_".$index] = array(
'#type' => 'image_button',
'#src'=> 'files/imghome/sidebar-add-demo.gif',
'#attributes' => array('rel' => '#item', 'class' => 'buybutton', 'title' => $discounttype),
'#prefix'=>'<p class="renewprop">'.$newren.' for '.$node_abb->field_tipo_abb_value.':</p><p class="renewblock"><span class="pricetag">'.$node_abb->field_prezzo_value.''.$discounttype.'</span>',
'#suffix' =>'</p>' ,
'#submit' =>array('usercp_form_submit'),
);
The form renders correctly, as you can see from this picture: http://cl.ly/3D2C2h1t1m2B351L1T31
(the N and R values beside the € symbol are actually the value of the $discounttype variable, just for checking it)
Each white box is basically an istance of the beforementioned form.
I need to pass the value of the $discounttype variable on each submit, so I decided to set it as the title of the submit button.
My problem is that in the submit function itself I cannot access the value of the 'title' attribute contained in the #attributes array. Mainly because probably I don't know the right syntax.
So far I've tried
$foo = $form_values['attributes']['title'];
$foo = $form_values['#attributes']['title'];
$foo = $form_values['attributes']['#title'];
And every other possible combination, but probably I'm just doing it wrong.
It's actually an hour that I'm crawling the web searching for an asnwer but I came up with anything.
first, you should mention form element ID.
so, you can access submit button by $form_state["cart_".$index]['#attributes']['title'];
but actually, why don't you use hidden field ('#type' => 'hidden') ?
I believe you have to use $form_state instead of $form_values. Give this a try:
$foo = $form_state['clicked_button']['#attributes']['title'];
I recommend using the Devel module while developing for Drupal. It is an extremely helpful tool during development, allowing you to see all the queries run when a page loads, stop a redirect to debug, and much more.