Yeoman generator : Copy directories and renaming them - yeoman-generator

I am new with Yeoman generator and manage to create a generator that generates a project from a template. However, my template folder contains directories and is it possible to rename the directory based on certain input or template pattern just like the file content ?
Following are my template directories.
dc_compid_sid
- db
- tool_compid_sid
- js_compid_sid
I would like to rename compid and sid when copy is done with the input values.
Following is my write code.
this.fs.copyTpl(
this.templatePath(),
this.destinationPath(),
{
compid : this.answers.compid,
sid : this.answers.sid
}
);
I read the documentation in Yeoman, mem-fs that allows copy options that eludes, this is possible with arguments passing in. However, I am new in nodejs/javascript coding and there is not many examples that I can rely on.
Hope somebody can help and guide.
Thanks.
Anand Muthu

Related

problem with #include file in template (laravel)

I'm trying to include many files to a blade file with dfr lang
#include("frontend.{$config->template}.privacy.Privacy-en")
#include("frontend.{$config->template}.privacy.Privacy-es")
#include("frontend.{$config->template}.privacy.Privacy-de")
.
.
.
I want one of these files to be imported according to the language chosen by the visitor
So I wrote this code as follows in page.blade.php
#include("frontend.{$config->template}.privacy.{'Privacy-' . LaravelLocalization::getCurrentLocale()}")
The error:
No hint path defined for [frontend.nova.privacy.{'Privacy-'. LaravelLocalization]. (View: C:\xampp\htdocs\templates\frontend\nova\page.blade.php)
any help will be highly appreciated.
Simple answer is don't do it this way. Laravel has built-in support for localisation, so there is no need to build different pages for each language and then jump through hoops - as you are trying to do - to try and incorporate the relevant one.
Read the documentation about localisation - in short, set up one blade template (called 'privacy.blade.php' for example) and within it use short keys such as :
{{ __('privacy.introduction') }}
and then define those keys within the relevant language files (so resources/lang/en/privacy.php, /fr/privacy.php, and so on) :
return [
'introduction' => 'The following statements set out our privacy information',
];

laravel proper way to extend(expand)/override specific vendor package file

the project I involved has composer require fengqi/hanzi into the vendor folder, which is used to convert simplified Chinese and traditional Chinese
For people who want to take a look at the package https://github.com/fengqi/hanzi
Inside the vendor folder, the package has the following example directory structure:
vendor/
--hanzi/
----src/
------Hanzi.php
------HanziDict.php
------Pinyin.php
The specific file HanziDict.php I want to modify has a really simple code structure:
<?php namespace fengqi\Hanzi;
return array (
'啊' => '啊',
...
...
'sample char A'=>'sample char B'
);
The github repository of the package suggested that I can insert any "char C => char D" inside the php file if I found the certain chars are missing from the dictionary.
But I believe I should not directly put the code inside vendor folder since it will be override after update.
So, my problem is how I can properly override/extend this file in Laravel (such as insert "char C => char D" into the array).
I already read and know how to properly extend class outside of vendor folder but did not find any useful information about other types of php files. I wonder if there is certain ways or rules to do with this kinds of files.
Ideally I want to achieve something like:
outside of the vendor folder, I have an expanded ExtraHanziDict.php. So it can always build upon the vendor dict.php.
The following links is the vendor class code (only fewer simple functions to read the dict and convert character)
https://github.com/fengqi/hanzi/blob/master/src/Hanzi.php (apology for throwing the code)
Unfortunately, in this case, there's no easy way to change the dictionary. As you correctly guessed you should never change the content of the vendor folder as it's not committed to version control.
In your specific case what you can do is:
Ask the repository mantainer to add an api that allows you to add new dictionaries at runtime.
Fork the repository, change what you need, and use that instead (see loading a custom git repository with composer). If you think your changes can be useful to others open a Pull request on the original repository.
There's no much logic on the repository you linked. Each package you add to your composer.json file is a burden, code that doesn't belongs to you and you MUST blindly thrust (what if at some point the repository is hacked and some malicious code hidden into it?). Just create your own service to do such a simple task.

include template from another extension ezpublish

In my current extension template i need to include template from another extension.
If i write
{include uri="design:article/full.tpl"}
it will search in my current extension. How can i direct it to other extension? According to doc there is a name parameter. What should be value of name?
https://doc.ez.no/eZ-Publish/Technical-manual/3.8/Reference/Template-functions/Miscellaneous/include
The design part of the design:article/full.tpl is already supposed to do what you want. It will search a article/full.tpl template, starting from a templates folder within your design folder extension/myextension/design.
eZ Publish will use the following rules to find the good template :
First : determinate which designs are used for the siteaccess. See the [DesignSettings] block in your site.ini files
[DesignSettings]
SiteDesign=a_design_specific_or_not_to_your_siteaccess
AdditionalSiteDesignList[]=another_generic_design
AdditionalSiteDesignList[]=standard
AdditionalSiteDesignList[]=base
Then : determinate which extensions are offering a design. See the [ExtensionSettings] block in each extension's design.ini file (exemple of the extension/ezflow/settings/design.ini.append.php) :
[ExtensionSettings]
DesignExtensions[]=ezflow
Finally, eZ Publish looks for the template. The SiteDesign design will be tried first, and then all the AdditionalSiteDesignList designs from top to bottom. Once the template is found, the lookup stops, and this information is cached (even if your TemplaceCache / TemplateCompile / ... is disabled). Remember the cache part, every time you add a new template, meant to be overriding another one, you need to clear the cache.
So if we have only 2 extensions offering a design, say ezflow and mysite, eZ Publish will try the following paths :
extension/mysite/design/a_design_specific_or_not_to_your_siteaccess/templates/full/article.tpl
extension/mysite/design/another_generic_design/templates/full/article.tpl
extension/mysite/design/standard/templates/full/article.tpl
extension/mysite/design/base/templates/full/article.tpl
extension/ezflow/design/a_design_specific_or_not_to_your_siteaccess/templates/full/article.tpl
extension/ezflow/design/another_generic_design/templates/full/article.tpl
extension/ezflow/design/standard/templates/full/article.tpl
extension/ezflow/design/base/templates/full/article.tpl
design/a_design_specific_or_not_to_your_siteaccess/templates/full/article.tpl
design/another_generic_design/templates/full/article.tpl
design/standard/templates/full/article.tpl
design/base/templates/full/article.tpl
Note that I made the hypothesis that the mysite extension has a higher priority than ezflow. See in settings/override/site.ini.append.php :
[ExtensionSettings]
ActiveExtensions[]
ActiveExtensions[]=mysite
....
ActiveExtensions[]=ezflow
....
This is for the system templates. The process is a little different when it comes to content templates (the ones which are used by attribute_view_gui and node_view_gui functions), see https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Templates/The-template-override-system

Silverstripe: Adding to the translation tables

I need to add additional translations to the Silverstripe 3 translation tables in sapphire/lang/[lang].yml
I am pulling in 'sapphire' as an SVN external so cannot just add the new values to the existing yml files.
Am I able to create additional language yml files for languages to add to these translations in mysite directory?
Yes, just create a new module with the following structure:
z_translations/
_config.php
lang/
en.yml
The z_ prefix ensures it comes alphabetically last, currently there's no way to influence loading order. the translations part can be anything. _config.php can be empty, but needs to be present for the folder to be detected as a module.
Note that in order to override translations in framework/admin/lang/, you have to create an admin subfolder in your module as well ... don't ask ;)

Magento - Make a copy of history.phtml and use it in my own way

I’m looking to find a way to copy the page history that we can access from My account/My orders which is available on this directory template/sales/order/history.phtml and use its content on my own way without affecting the original one. I’ve been trying many ways, as copying the whole directory and editing the Xml files related to it in order to setup up the right path and make it work, unfortunately it was a failure. I would like to know if you could give me a solution for this.
thx.
To use the functions of a block inside another .phtml I'm quite sure you can use getBlock
$blockFunctions = $this->getLayout()->getBlock('sales/order_history');
$order = $blockFunctions->getOrderHistory();
And to add a block in your custom module you'll need to create a .xml file for your block and add it to your template, you'll also have to add the actual .phtml file. Take a look at the moduleCreator (http://www.magentocommerce.com/magento-connect/danieln/extension/1108/modulecreator) this handles most of this quite well.
This is by no means througher its just a rough guide.

Resources