Following structure:
apps/backend/
apps/frontend/
modules/
account/template/_menu.php
account/template/test.php
settings/template/indexSuccess.php
I do include _menu in test.php with the following code:
<?php slot('menu'); ?>
<?php include(dirname(__FILE__).'/_menu.php') ; ?>
<?php end_slot() ?>
How can I include the file _menu.php in indexSuccess.php?
Thanks!
Gunnar
You want to use include_partial from the indexSuccess.php template:
// indexSuccess.php
// Use the array container to pass values available in indexSuccess to your partial
<?php include_partial('menu', array(
'foo' => $foo,
'bar' => $bar
)) ?>
You can read more about it in Symfony API Docs.
Related
Hello I Have inside {root_dir}/src/veo/SomeBundle/Controller/SomeController.php
return $this->render('index.html.twig', array(
"article" => $articles
));
As default symfony includes {root_dir}/templates/
How can I override this to {root_dir}/src/veo/SomeBundle/Resource/views/
I resolved this by adding namespace inside config/packages/twig.yaml
twig:
default_path: '%kernel.project_dir%/templates'
paths:
"%kernel.project_dir%/src/Veo/SomeBundle/Resources/views": foo_bar
when#test:
twig:
strict_variables: true
and inside Controller:
return $this->render('#foo_bar/Anomalies/index.html.twig', array(
I am using PHP Laravel, I can find PHP SDK, But I can't find any examples.
I need to call ResolveCustomer (produces a token for the product and user) and GetEntitlements (gives a list of rights for the product and the user).
Has anyone used this service?
I write this code works.
<?php
require 'aws/aws-autoloader.php';
use Aws\AwsClient;
use Aws\Credentials\Credentials;
use Aws\MarketplaceMetering;
$config = [
'credentials' => new Credentials('key', 'secret'),
'region' => 'us-east-1',
'version' => 'latest'
];
$client = new MarketplaceMetering\MarketplaceMeteringClient($config);
$x_amzn_marketplace_token = 'token';
$result = $client->resolveCustomer(['RegistrationToken' => $x_amzn_marketplace_token]);
echo "<pre>";
print_r($result);
How can I use Pjax in Yii 2 with POST request?
I tried to do it like that but page restarts anyway:
<?php Pjax::begin(['id' => 'some-id', 'clientOptions' => ['method' => 'POST']]);?>
...
some content
...
<?=Html::a('', ['cart/cart'],
['class'=>'close1',
'data' => [
'method' => 'post',
'params' => [
'idCartToDelete' => $product->idCart,
],
]
]
)
?>
...
some content
...
<?php Pjax::end(); ?>
You're close to solving your issue. To your Html::a parameters add:
'data-pjax' => 0,
And you will have a link that does not redirect to another page.
I am using the following code in Yii2:
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'link')->widget(MaskedInput::classname(), [
'clientOptions' => [
'alias' => 'url',
],
]) ?>
<?php ActiveForm::end(); ?>
It seems, that the input field is limited to 60 characters. How to remove this limitations?
See the URL example on: http://demos.krajee.com/masked-input
The limitation is in jquery.inputmask. See https://github.com/RobinHerbots/jquery.inputmask/issues/863. This limitation will disappear if the issue is solved and the new jquery.inputmask.js is included in Yii2 bower package.
I have a very simple xml file that I am trying to access:
<article>
<text>hello world</text>
</article>
I'm doing this so far:
file = File.open("#{Rails.root}/public/files/#{file_id}.xml", "r")
xml = file.read
doc = REXML::Document.new(xml)
When I run this code in rails console, I see:
1.9.3-p194 :033 > doc.inspect
=> "<UNDEFINED> ... </>"
I can't seem to understand why it is not loading the file correctly, I can't access the text xml element either.
It is loading correctly, the document just doesn't have a root node.
require "rexml/document"
doc = REXML::Document.new DATA.read
doc.root_node # => <UNDEFINED> ... </>
doc.inspect # => "<UNDEFINED> ... </>"
doc.to_s # => "<article>\n <text>hello world</text>\n</article>\n"
doc.get_elements('//article') # => [<article> ... </>]
doc.get_elements('//text') # => [<text> ... </>]
__END__
<article>
<text>hello world</text>
</article>
By the way, I think the Ruby community has pretty much universally endorsed Nokogiri for xml parsing.