Here's my code:
<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
if (!is_null($primarySidebar->getChild('Service Details Actions'))) {
$primarySidebar->getChild('Service Details Actions')
->addChild('Check', array(
'label' => 'Checker',
'uri' => 'http://example.com/check/'.print_r($vars['params']['domain']).'-check',
'order' => '3',
));
}
});
I am wanting the uri to link to here (assuming $domain = testdomain.com):
http://example.com/check/testdomain.com-check
Instead, it is showing this right now:
http://example.com/check/1-check
This is the specific line that I guess I'm having trouble with:
'uri' => 'http://example.com/check/'.print_r($vars['params']['domain']).'-check',
What am I doing wrong here?
The call to print_r() is unnecessary. Assuming that the string "testdomain.com" is stored in $vars['params']['domain'], then you simply need to concatenate the variable with the string like this:
'uri' => 'http://example.com/check/'.$vars['params']['domain'].'-check',
The function print_r() prints readable information about the given variable. Typically it is only used for debugging.
Related
I'm trying to pass data about the page state (navbar links having active class when you are in that exact page), page title. I do so with an indexed array $pageInfo, however I am getting a syntax error and doen't know where?
Also do you think this is a good method or should I use view->share() instead?
public function clases()
{
$pageInfo[] =
(
'page_title' => 'Clases',
'menu_active' => 'CLases',
'sub_menu_active' => '',
);
return view('clases.list', compact('pageInfo'));
}
public function domicilio()
{
$pageInfo[] =
(
'page_title' => 'Clases a domicilio',
'menu_active' => 'Clases',
'sub_menu_active' => 'Clases a domicilio',
);
return view('clases.domicilio', compact('pageInfo'));
I suggest you read PHP basic syntax.
Basically you want to do this:
$pageInfo =
[
'page_title' => 'Clases',
'menu_active' => 'CLases',
'sub_menu_active' => '',
];
Arrays have a syntax of [key => val, ...] in PHP, you're using () as it seems.
Also $someArray[] = someValue, will append the someValue to an existing array, in your case that would create another, unwanted level of your array.
And last, you're not ending the domicilio() function. But I'll assume you just didn't paste it in (you should add } at the end, if that's not the case).
I'm new to theming and I just inherited this code. I need to control where and how to print #output but it's always showing up at the top of the page, above the HTML tags. I looked at the renderable arrays API but I couldn't find anything specific to my problem.
In mytheme.module:
function mytheme_output_block() {
$content = array(
'#theme' => 'my_theme',
'#output' => function_that_returns_JSON();
...
function mytheme_hook_theme() {
return array(
'my_theme' => array(
'vars' => array(
'output' => '',
...
And in my_theme.tpl.php I tried:
<?php print $output; ?>
But it gets ignored. How do I control #output so I can style it?
not super sure but you might need to call the array element directly. Something like:
$theme = mytheme_hook_theme();
echo $theme['output'];
Hope it helps
Which Drupal you use? I assume D7.
Take a look at the documentation of hook_theme: https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_theme/7.x
It's not vars - it's variables
You have missed the template key in your implementation
template: If specified, this theme implementation is a template, and this is the template file without an extension. Do not put .tpl.php on this file; that extension will be added automatically by the default rendering engine (which is PHPTemplate). If 'path', above, is specified, the template should also be in this path.
So what your hook should look like:
function mytheme_hook_theme() {
return array(
'my_theme' => array(
'variables' => array(
'output' => '',
),
'template' => 'my-theme',
...
Remember to clear the caches afterwards.
I am working in wordpress and using buddypress theme. In my php file i want to set value of a buddy press functions into an array parameter like following
PLUGIN_METHOD( array( 'Para1' => 'Value1', 'Para2' => bp_activity_user_link()));
But i am unable to set value of function's into array.
Please suggest me right way.
Thanks in advance!
That function echos the result and returns void, so it won't get passed to the array. Use this function:
bp_get_activity_user_link();
Ok, last try :). It's possible your version of BP doesn't have that function. You can try this:
ob_start();
bp_activity_user_link();
$link_out = ob_get_contents();
ob_end_clean();
PLUGIN_METHOD( array( 'Para1' => 'Value1', 'Para2' => $link_out));
PLUGIN_METHOD( array( 'Para1' => 'Value1', 'Para2' => bp_activity_user_link(); ) );
^
You just have to fix the parse error by removing your ; after the nested function call and that's it
PLUGIN_METHOD( array( 'Para1' => 'Value1', 'Para2' => bp_activity_user_link()));
I'm developing a site for analyzing a store's data.
I need the url part of my array to look like this:
array(
'url' => 'http://some.website.com:8080/SASStoredProcess/do?_username=user-123',
'_password' => 'passwd',
'_program' => '/Utilisateurs/DARTIES3-2012/Mon dossier/analyse_dc',
'annee' => '2012',
'ind' => 'V',
'_action' => 'execute'
);
I currently have this and am struggling to convert it to the desired format:
array(
'url' => 'url=http://some.website.com:8080/SASStoredProcess/do?_username=user-123&_password=passwd&_program=%2FUtilisateurs%2FDARTIES3-2012%2FMon+dossier%2Fanalyse_dc&annee=2012&ind=V&_action=execute',
'otherKey' => 'otherValue'
);
Please can somebody help me to convert the URL in the second code block to look like the first code block? Thanks in advance.
So this will extract the url in the form you want, as $url:
$myArray = array(
'url' => 'url=http://some.website.com:8080/SASStoredProcess/do?_username=user-123&_password=passwd&_program=%2FUtilisateurs%2FDARTIES3-2012%2FMon+dossier%2Fanalyse_dc&annee=2012&ind=V&_action=execute',
'otherKey' => 'otherValue'
);
parse_str($myArray['url']);
echo $url;
You will need to decide where it needs to go next and how you get it there.
You might want to use: parse_url() and parse_str() over your $array['url']
I'm using drupal's l() function to build a link. So I'm passing this variable as a second argument that the function will generate the href value from.
$performer = $row->node_field_data_field_evenement_performer_title;
$url = 'node/' . $row->node_field_data_field_evenement_performer_nid . '/lightbox2';
print l($performer, $url, array('html' => TRUE, 'attributes' => array('rel' => 'lightframe[group|width:500px; height: 500px][caption]', 'class' => 'performer-link')));
The URL should end with the query string ?format=simple. So basically my $url variable should be updated something like:
$url = 'node/' . $row->node_field_data_field_evenement_performer_nid . '/lightbox2?format=simple';
No matter what encode/decode function I wrap around, and whatever escaping I do, that question mark and equals sign keep getting interpreted as %25 types of characters.
I tried:
$url = 'node/' . $row->node_field_data_field_evenement_performer_nid . '/lightbox2\?format\=simple');
or
'/lightbox2' . any_decode_or_encode_function_outthere('?format=simple');
but I keep getting URLs like node/202/lightbox2%5C%3Fformat%5C%3Dsimple.
Use the query key for the options array passed to l():
print l($performer, $url, array(
'html' => TRUE,
'attributes' => array(
'rel' => 'lightframe[group|width:500px; height: 500px][caption]',
'class' => 'performer-link'
),
'query' => array(
'format' => 'simple'
)
));
l() calls url() internally, and options can be forwarded on. See the docs for url()
Try l($performer, $url, array('query' => array('format' => 'simple'), /*...the rest of your array...*/ );
This is for drupal 7. In the options array you can specify a query array which is a key-value array of things to append to the url query string.