Please see the attached image below. I need to get the highlighted value via PHP and put it into one of my templates. I'm not exactly sure how this works, but this text is created as part of an entityform .
You need to implement hook_form_alter in order to access a form element. Kindly read the documentation about how to use it.
Then, you can access the field like that:
$value = $form[YOUR_FIELD]['#items'][0]['value'];
Hope this works... Muhammad.
Related
I'm working with a custom made plugin that a company provides and I need to fill a variable with there fields.
The provide the following macro:
$voertuig->verkoopprijs_particulier->value();
I try to use that with this snippet:
$productprijs = $voertuig->verkoopprijs_particulier->value();
echo $productprijs;
(The echo is for testing, I'm using that variable elsewhere).
But the problem with that is, it does not generate correctly.
What I get is the following:
€ 1.900,-->value()
Any advise on how to get the full macro to be used in my variable?
Turned out to be a bug inside the plugin. Not the code. so solved.
I'm stuck with a php/mySQL thing..
I have a dynamically created form and I want to parse the $_POST variables it generates. To be specific,I have a query in SQL which generates the fields in my form. Then, I need to process these variables in the php file, where the action of the form goes.
However, I cannot parse the dynamically created $_POST variables. Below is my code:
$sql="just-a-query";
$result = mysql_query($sql);
while ($data = mysql_fetch_array($result)) {
${''.$data['parameterName']}=$_POST[$data['parameterName']];
}
For example, if I have 3 variables that got through the form the values:
house=1
tree=3
car=2
I would like to save them via php like this:
$house=$_POST['house'];
$tree=$_POST['tree'];
$car=$_POST['car'];
However I can't get through it. It returns Undefined index error. Any thoughts?
If you want to find if a variable is defined before using it, it's as simple as using isset():
if( isset($_POST[$data['parameterName']]) ) {
${''.$data['parameterName']}=$_POST[$data['parameterName']];
}
If on the other hand, it's supposed to be defined (you see the form element), but then it's not getting defined in the postback. First check to make sure that your form submission type is post, then check to make sure you are using the name attribute in the form elements.
thank you for your time. My problem was that I was parsing wrong parameters from the HTML.
Yes, I'm an idiot and yes, var_dump() helped me to figure my error.
Thanks again!
btw, my code was working perfectly. Ha!
I have a MediaWiki installation and I'm writing a custom script that reads some database entries and produces a custom output for client.
However, the text are in wiki format, and I need to convert them to HTML. Is there some PHP API I could call -- well there must be, but what and how exactly?
What files to include and what to call?
You use the global object $wgParser to do this:
<?php
require(dirname(__FILE__) . '/includes/WebStart.php');
$output = $wgParser->parse(
"some ''wikitext''",
Title::newFromText('Some page title'),
new ParserOptions());
echo $output->getText();
?>
Although I have no idea whether doing it this way is a good practice, or whether there is some better way.
All I found is dumpHTML.php that will dump all your mediawiki ; or may be better API:Parser wiki text which tells :
If you are interested in simply getting the rendered content of a
page, you can bypass the api and simply add action=render to your url,
like so: /w/index.php?title=API:Parsing_wikitext&action=render
Once you add action=render it seems you can get the html page ; dont you think ?
hope this could help.
regards.
hello how to set a value in php variables from fbml(facebook markup language)
<fb:comments-count href=http://domain.com/view/24></fb:comments-count>
please share your idea :)
I think what you're trying to do is get the number of comments for a certain page. In that case you shouldn't do it via FBML but instead make a REST call: http://developers.facebook.com/docs/reference/fbml/comments_(XFBML)/
You'll see that you can do a call along the lines of https://api.facebook.com/method/fb:comments?access_token=https://api.facebook.com/method/fb:comments?access_token=FOO
I used the auto-complete function in jquery. It's data source are the results from a php-back-end.
$("#ice_id").autocomplete("ice-ver.php", { extraParams : { flavour_id: $("#flavour_id").val() } });
Let us take following example:
We type in the flavour ID 3992 ...(and 3992 exists in the database and is properly returned by the php backend). If we type in now 3992999 the auto-complete function should top showing anything up ...but unfortunately it still does, (could the problem lie within the fact that I am using integers instead of strings or chars?)
Thanks in advance for any hints and
best regards
Daniyal
if it's showing something doesn't that mean there is a result from the php code? Check if it's really how you want it, and if you post it someone might be able to help
I agree with shyam. It seems like your PHP-code returns values. Try to request the PHP-script directly in a browser through the-url-to-php-script?flavour_id=3992999.
There are different autocomplete plugins for jquery. If you instead use the one at jquery ui (http://jqueryui.com/demos/autocomplete) your entered value are automatically passed to the URL-resource as the parameter "term". See if that helps you in pinning down the problem with the PHP-script.