I am using kartik mpdf in YII2. And I need to show the full header in every page. It may have a height of 450px.
Currently it's shown as above. How can I fix it?
marginTop: float, sets the page top margin for the new document (in millimetres).
You can use 'marginTop' => 119
The margins can be set using the syntax below, for the top margin adjust the marginTop as required
new Pdf([
'mode' => '', // leaner size using standard fonts
'format' => Pdf::FORMAT_A4,
'orientation' => Pdf::ORIENT_LANDSCAPE,
'marginTop' => 0,
'marginBottom' => 0,
'marginLeft' => 0,
'marginRight' => 0,
'destination' => Pdf::DEST_BROWSER,
'content' => $this->renderPartial('certificate_pdf', ['']),
'options' => [
// any mpdf options you wish to set
],
'methods' => [
'SetTitle' => '',
'SetSubject' => '',
'SetHeader' => [''],
'SetFooter' => [''],
'SetAuthor' => 'Ajira Tracking',
'SetCreator' => 'Ajira Tracking',
'SetKeywords' => 'Ajira Tracking',
]
]);
Related
1) I have my Yii2 in subfilder, so all my link starts from Yii/, like http:/localhost/Yii/settings/usertype-activitytype/type/3
2) request component config
'request' => [
'cookieValidationKey' => 'somecookiekey',
'baseUrl' => '/Yii',
],
3) Trying to build Menu, current route is http:/localhost/Yii/settings/usertype-activitytype/type/1 the 1 is id in route, and I should specify current route as Yii::$app->request->pathInfo for Nav widget
Attempt 1 - no bracets as string NOT FIND ACTIVE ELEMENT
Nav::widget([
'items' => array_map(function($userType) {
return [
'label' => $userType->name,
'url' => Url::current(['id' => $userType->id]),
];
}, $userTypes),
'route' => Yii::$app->request->pathInfo,
'options' => ['class' =>'nav-pills'],
]);
Attempt 2 - use bracets as route NOT FIND ACTIVE ELEMENT
Nav::widget([
'items' => array_map(function($userType) {
return [
'label' => $userType->name,
'url' => [Url::current(['id' => $userType->id])]
];
}, $userTypes),
'route' => Yii::$app->request->pathInfo,
'options' => ['class' =>'nav-pills'],
]);
Attempt 3 - remove baseUrl from generated route FIND ACTIVE ELEMENT !!!
Nav::widget([
'items' => array_map(function($userType) {
return [
'label' => $userType->name,
'url' => [str_replace('Yii/', '', Url::current(['id' => $userType->id]))]
];
}, $userTypes),
'route' => Yii::$app->request->pathInfo,
'options' => ['class' =>'nav-pills'],
]);
So you should notice I have to use dirty hack to force Nav work with generated Url, it seems very unconvient.
The question is - is there are ways to force NAV widget to recognize current active item ?
If you want buil an url based on your param you should use Url::to()as
'url' => Url::to(your-controller/your-view', ['id' => $userType->id]),
so accessing the view type for controller usertype-activitytype
'url' => Url::to('usertype-activitytype/type', ['id' => $userType->id]),
current Creates a URL by using the current route and the GET parameters.
and remember that
By Design UrlManager always prepends base URL to the generated URLs.
By default base URL is determined based on the location of entry
script. If you want to customize this, you should configure the
baseUrl property of UrlManager.
Looking to your comment the url is correcly formed .. then if you need http:/localhost/Yii instead of Yii then you can:
don't set so the localhost ... url is atomatically created
OR add the proper base url configureation as http:/localhost/Yii/ in config /main and remember that you can use main.php and main-local.php for manage different congiguration
When I try
$this->size(array('width' => 960, 'height' => 400));
I get "BadMethodCallException: The command 'size' is not existent or not supported yet."
I've also tried this
$win = $this->window("")->size(array('width' => 960, 'height' => 400));
but that just gets me a null object.
You may try the methold currentWindow()
$win=$this->currentWindow();
$win->size(array('width' => 960, 'height' => 400));
I am working with gem "gmaps4rails" in rails 3.2.12, I had set the detect_location = "true" in map_options, but it is not showing any marker with user current location.
Here is code:
<%= gmaps("map_options" => {"auto_adjust" => true, "detect_location" => true, "center_on_user" => true, "auto_zoom" => false, "radius" => 2500},
"markers" => {"data" => #json, "options" => {"list_container" => "markers_list","randomize" => true,"max_random_distance" => 10000, "draggable" => true, "dblclick" => "latLng"} }
How to show with marker for the user current location.
Please help me.
Thanks in Advance
With the gem "gmaps4rails",
if we give the option "detect_location" => true, when the map loads on page, it shows pop-up to user as 'allow application to use your location' and gives yes and no as options.
If user selects 'yes', then map get centered to user's location.
Now here you want to display marker for user's location, then you have to add marker by your own.
This can be done as follows:
Controller:
geo = request.location
#latitude = geo.latitude
#longitude = geo.longitude
With your page load, you can add marker for user, with this callback.
This would add marker for current user location when map loads on page.
- content_for :scripts do
%script{:type => "text/javascript"}
Gmaps.map.callback = function(){
google.maps.event.addListenerOnce(Gmaps.map.serviceObject, 'idle', function(){
/ add user pin
var home_pin = [{picture: "current_user.png", width: 32, lat: "#{#latitude}", lng: "#{#longitude}"}];
Gmaps.map.addMarkers(home_pin)
}
)};
Hope this would help you.
Let me know if you still face any issues.
Thanks.
I'm trying to install the ZendDeveloperTools modules for ZF2 beta5. Here are the steps I followed so far:
-Successfully installed ZendSkeletonApplication.
-Downloaded the module into my ./vendor directory.
-Enabled the module in ./config/application.config.php:
<?php
return array(
'modules' => array(
'Application',
'ZendDeveloperTools', // Added this line
),
'module_listener_options' => array(
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
),
'module_paths' => array(
'./module',
'./vendor',
),
),
);
-Copied ./vendor/ZendDeveloperTools/config/zenddevelopertools.local.php.dist to ./config/autoload/zenddevelopertools.local.php.
-Edited zenddevelopertools.local.php as follows:
<?php
return array(
'zdt' => array(
'profiler' => array(
'enabled' => true,
'strict' => true,
'verbose' => true,
'flush_early' => false,
'cache_dir' => 'data/cache',
'collectors' => array(),
'verbose_listeners' => array('application' => array(
'ZDT_TimeCollectorListener' => true,
'ZDT_MemoryCollectorListener' => true,
))
),
'toolbar' => array(
'enabled' => true,
'auto_hide' => false,
'position' => 'bottom',
'version_check' => false,
'entries' => array(),
),
),
);
-Added define('REQUEST_MICROTIME', microtime(true)); in my ./public/index.php
-Replaced my ./composer.json with the one provided in the ZendDeveloperTools module.
-Removed the , at the end of line 29 which was causing problems (shouldn't be there):
-Ran a composer update :
$ php composer.phar update
Updating dependencies
- Updating zendframework/zendframework (dev-master)
Checking out 9f4dd7f13c8e34362340072d0e2d13efe15e4b1f
Writing lock file
Generating autoload files
-Added error_reporting(E_ALL); ini_set('display_errors', '1'); to ./public/index.php to catch potential errors
When I access my application I don't get any errors (I get the skeleton application home page) but the zend developer toolbar isn't show up
What am I missing to make use of and display the zend developer toolbar?
It was a stupid mistake, I had placed zenddevelopertools.local.php into ./config and not ./config/autoload. Above instructions are correct. Here is what the toolbar looks like for those who are curious:
Worked for me, but one change I had to make for my app was rename the config from:
zenddevelopertools.local.php
to:
zenddevelopertools.local.config.php
Also, I installed BjyProfiler, which "just worked" with my Doctrine2 setup (nice!). The only caveat was that I had to add the default SM factory config so it would stop throwing errors:
'service_manager' => array(
'factories' => array(
/**
* This default Db factory is required so that ZDT
* doesn't throw exceptions, even though we don't use it
*/
'Zend\Db\Adapter\Adapter' => function ($sm) use ($dbParams) {
$adapter = new BjyProfiler\Db\Adapter\ProfilingAdapter(array(
'driver' => 'pdo',
'dsn' => 'mysql:dbname=skunk;host=hunk',
'database' => 'bunk',
'username' => 'junk',
'password' => 'punk',
'hostname' => 'lunk',
));
$adapter->setProfiler(new BjyProfiler\Db\Profiler\Profiler);
$adapter->injectProfilingStatementPrototype();
return $adapter;
},
),
),
See the screenshot:
I'd like to upload multiple files using Form API.
'#type' => 'file' provides upload only one file.
$form['picture_upload'] = array(
'#type' => 'file',
'#title' => t(''),
'#size' => 50,
'#description' => t(''),
'#weight' => 5,
);
How can i provide multiple upload?
Aside from putting the form element in a for loop, I would suggest (for now) using the plupload form element.
http://drupal.org/project/plupload
Then:
$form['picture_upload'] = array(
'#type' => 'plupload',
'#title' => t(''),
'#size' => 50,
'#description' => t(''),
'#weight' => 5,
);
This is similar to a issue I had: Drupal 7 retain file upload
You can use managed_file element type instead of file
here's the drupal documentation: http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/7#managed_file