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.
Related
I'm using the following library to give a update feature to my WordPress and this works fine with the code of documentation.
https://github.com/YahnisElsts/plugin-update-checker/blob/master/README.md
require 'plugin-update-checker/plugin-update-checker.php';
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'https://github.com/user-name/repo-name/',
__FILE__,
'unique-plugin-or-theme-slug'
);
But I'm really wondering where this '$myUpdateChecker' variable came from and how this is working, because I can't find any part of the library's files using this variable.
It seems to be totally independent for me.
Thank you in advance.
You're creating the variable right there. You can even name it something else if you want (eg. $update_checker), that shouldn't cause any issues in this particular case as the variable isn't being used anywhere else (according to your own words.)
For more details: PHP variables.
I have built a custom CMS. Recently, I added the ability to create pages dynamically. I used CKEditor for the content of these pages.
I would also like to run some php functions that may be included in the content of the page stored in mysql.
I DO NOT want to store actual PHP code in the database, but rather function names perhaps. For example, in a page stored in the database I may have.
<?php //begin output
hello world!
check out this latest news article.
news($type, $id);
//end output
?>
What is the best way to find and execute this existing function without using EVAL if its found in the output? I was thinking along the lines of wordpress style short codes. Maybe [[news(latest, 71]] ? Then have a function to find and execute these functions if they exist in my functions.php file. Not really sure the best way to go about this.
I'm not searching for any code answers, but more of a best practice for this type of scenario, especially one that is safest against possible injections.
I found a solution from digging around and finding this thread
How to create a Wordpress shortcode-style function in PHP
I am able to pass short codes like this in CKEditor
[[utube 1 video_id]]
Then, in my page that renders the code:
print shortcodify($page_content);
using this function:
function shortcodify($string){
return preg_replace_callback('#\[\[(.*?)\]\]#', function ($matches) {
$whitespace_explode = explode(" ", $matches[1]);
$fnName = array_shift($whitespace_explode);
return function_exists($fnName) ? call_user_func_array($fnName,$whitespace_explode) : $matches[0];
}, $string);
}
If the function name exist (utube) it will fire the function.
Only problem Im having at the moment is not matter where I place the [[shortcode]] in my editor, it always executes first.
For example, in CKEditor I put:
Hello world! Check out my latest video
[[utube 1 video_id]]
It will always put the text under the video instead of where it is in the document. I need to figure a way to have the short code execute in the order it is placed.
I have been trying to write a plugin on elgg framework. So I tried to call specific css for a particular page by using elgg_extend_view() function which is not working. For example
if(elgg_get_context()){
elgg_extend_view('css/elgg', 'myplugin/css');
}/*This works*/
But the following doesnt seem to work
if(!elgg_get_context()){ //If there is not elggcontext call no_css file
elgg_extend_view('css/elgg', 'myplugin/no_css');
}/*This is not working */
Can anybody tell me why?
Apparently, you're misinterpreting expected behavior of elgg_get_context function.
Check: http://reference.elgg.org/pageowner_8php.html#a25fe73eb19442b4a4476f18e63abf382 It uses strings as a context name (it has to be pushed first and is expected usually to be set just before pagesetup event)
Conditional extension of elgg/css won't work correctly, due to caching. You probably want to use elgg_register_css and elg_load_css instead.
elgg_get_context() returns STRING or NULL
The exclamation (!) is not good in this case.
Try:
if(null!==elgg_get_context()){ //If there is not elggcontext call no_css file
elgg_extend_view('css/elgg', 'myplugin/no_css');
}
If any problem try to visualize what the function is returning, see:
var_dump(elgg_get_context());
Note: elgg is in version 1.8.18, check if you have updated the code.
The best way to do this is to compare your plugin's context, as elgg will always maintain some context.
so do it like:
if(elgg_get_context() == 'myplugin'){
elgg_extend_view('css/elgg', 'myplugin/css');
}
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.
I'm trying to output some HTML in an XML template and Symfony's escaping method is messing it up. So I tried making a copy of settings.yml in the module's config folder, but it seems to be completely ignored. Is there an easy way to change the escaping_strategy and/or escaping_method settings per module or even per template?
While output escaping is turned on you still have access to the raw value through $sf_data. For example, if the HTML you're trying to output was stored in a variable called html in your action:
$this->html = '<b>My HTML</b>';
You could get the unescaped value with this:
<?php echo $sf_data->getRaw('html') ?>
http://www.symfony-project.org/book/1_0/07-Inside-the-View-Layer#chapter_07_sub_activating_output_escaping
I don't believe there is a way to disable this functionality on a per-module basis.
getRaw only works if the variable is passed from the action. for variable within view use
sfOutputEscaperGetterDecorator::unescape($html)
Just run into this problem today and i manage to solve it by setting sfConfig::set('sf_escaping_strategy', false) in my controller (either in preExecute method for all the actions in that module or in a specific action - executeWhatever).