I have a RelationList field for Dexterity Type Info to relate with another Type Venue :
venue = RelationList(
title=_(u'Venue'),
value_type=RelationChoice(
source=ObjPathSourceBinder(
object_provides=IVenue.__identifier__,
),
),
required=False,
)
Venue items are created in a specific folder, /info, how can I make browsing directly starting from the /info folder, instead of from the / folder ?
My instance now runs on Plone 4.2.4 and plone.app.dexterity 1.2.1.
To limit the path of the ObjPathSourceBinder one could do the following:
[...]
source=ObjPathSourceBinder(navigtion_tree_query = {
"object_provides":"IVenue.__identifier__",
"path": {"query":"/my/path" }
}
),
or you could just add a "path" argument to your code:
[...]
source=ObjPathSourceBinder(
object_provides,IVenue.__identifier__,
path={"query":"/mysite/media"},
),
The navigation_tree_query argument ist described here:
Related
I'm trying to add custom domain into the project.
I have regions.locale.yaml file.
I'm trying load it in twig:
{{'united.kingdom'|trans|raw}}
But this doesn't work.
I think it has to be somehow declared that this file exists.
I found this in documentation:
// ...
$translator->addLoader('xlf', new XliffFileLoader());
$translator->addResource('xlf', 'messages.fr.xlf', 'fr_FR');
$translator->addResource('xlf', 'admin.fr.xlf', 'fr_FR', 'admin');
$translator->addResource(
'xlf',
'navigation.fr.xlf',
'fr_FR',
'navigation'
);
But where should I put this to declare my regions.locale.yaml files globally?
Thanks
If you are using Symfony Standard, you don't have to declare your translation files, you just put them in app/Resources/translations.
The key is that when you want to translate using your custom domain, you just specify your domain, like this :
{{'united.kingdom'|trans({}, 'regions')|raw }}
or somewhere else in your code :
$translator->trans('united.kingdom', [], 'regions');
Working with Laravel 5.3, I'm trying to pass part of my url into a controller function dynamically with no luck so far. When a link is clicked on http://127.0.0.1:8000 page, the url becomes http://127.0.0.1:8000/politics. How can I pass the politics part into my controller function? Below is what I have in my
web.php routes file
Route::get('/{$category}', 'PostController#category');
PostController.php file
public function category($category)
{
$tag = $category;
$posts = Post::where('tag', '=', '{tag}');
return view('post', compact('posts'));
}
php artisan tinker
Psy Shell v0.8.1 (PHP 5.6.16 ΓÇö cli) by Justin Hileman
>>> $tag = 'politics'
=> "politics"
>>> $post = App\Post::where('tag', '=', '{tag}')->get();
=> Illuminate\Database\Eloquent\Collection {#671
all: [],
}
>>>
So after reviewing the code and putting a small demo together locally there is only one minor reason as to why this is failing.
{varName} variables are already recognised as a variable so you don't need to define it as $varName like you are currently ({$category})
The following code should give you a working example:
Create a controller called DemoController.
Inside this file put the following:
public function demo($category)
{
dd($category);
}
Inside your routes\web.php route file add the following line"
Route::get('/mena/{category}', 'DemoController#demo');
Now, when you go to www.website.com/mena/politics you should see it print politics to the screen.
I'm doing a widget with dashing.io and I would like to change the jenkins jobs according to the color I receive in my json file (wich I get from the Jenkins API).
ie: The job is complete, I get the color value "blue" from my json file and I want the text to be blue on the "widget jenkins" i my dashboard.
Problem: I don't really know how to get my data from my json file in my coffeescript script. Neither I know how to change the css.
My json file goes like this:
{
"assignedLabels" : [
{
}
],
"mode" : "NORMAL",
"nodeDescription" : "blabla",
"nodeName" : "",
"numExecutors" : blabla,
"description" : blabla,
"jobs" : [
{
"name" : "JOB_NAME",
"url" : "MY_JOB_URL",
"color" : "blue"
}
]
}
Here is my widget code:
require 'net/http'
require 'json'
require 'time'
JENKINS_URI = URI.parse("jenkins_url")
JENKINS_AUTH = {
'name' => 'user',
'password' => 'pwd'
}
def get_json_for_master_jenkins()
http = Net::HTTP.new(JENKINS_URI.host, JENKINS_URI.port)
request = Net::HTTP::Get.new("/jenkins/api/json?pretty=true")
if JENKINS_AUTH['name']
request.basic_auth(JENKINS_AUTH['name'], JENKINS_AUTH['password'])
end
response = http.request(request)
JSON.parse(response.body)
end
# the key of this mapping must be a unique identifier for your job, the according value must be the name that is specified in jenkins
SCHEDULER.every '100s', :first_in => 0 do |job|
thom = get_json_for_master_jenkins()
send_event('master_jobs',
jobs: thom['jobs'][0..4],
colors:thom['jobs']['color']
)
end
Could you guys help me ? I'm really new to this, try to make it simple please.
OK, I think I found the answer.
Jenkins is built on batman.js, and there is a way to interact with the DOM.
I use the provided batman.js attribute data-bind-class like this in my widget HTML:
.blue{
#CSS stuff goes here
}
I use silverstripe 3.1
I would like to limit the languages (To only German and English) which are available in the drop down in the CMS. Therefore I put
the following code in my mysite/_config.php
i18n::set_locale('de_DE');
$allowed_locales = array(
'de_DE' => array('Deutsch', 'Deutsch'),
'en_EN' => array('English', 'English')
);
i18n::$common_locales = $allowed_locales;
Afer a flush=1 i get the following error:
Fatal error: Cannot access private property i18n::$common_locales in ... _config.php
Any ideas what goes wrong?
Thank you
as of 3.1 most of the static php variables are private. this means you can no longer access those.
the reason for this api change is that they are now cached by the config layer (this is also why you have to ?flush=1 now after changing private statics in classes like for example with private static $db)
if you want to update something in the config layer, you can do this with:
Config::inst()->update('CLASS', 'FIELD', $value);
you could use use the config update to overwrite the common locales (class would be 'i18n', and field would be 'common_locales'):
Config::inst()->update('i18n', 'common_locales', $array);
Note: if you want to completely overwrite an existing configuration, you have to do a remove() first.
Config::inst()->remove('i18n', 'common_locales');
Config::inst()->update('i18n', 'common_locales', $array);
however, if you are using the translatable module and you want to limit the number of translatable languages, there is a much better way already built in:
// in your _config.php
i18n::set_locale('en_US');
Translatable::set_allowed_locales(array(
'de_DE',
'en_US',
));
Config it through YAML:
i18n:
common_locales:
nl_BE:
name: Dutch (Belgium)
native: Nederlands
fr_BE:
name: French (Belgium)
native: Francais
OK... let me start by saying I know there is a similar post here (How to create a Drupal rule to check (on cron) a date field and if passed set field "status" to "ended"?) but the answer on that post does not work. Step 4 (In the component add the condition 'Data comparison' and select node:type) does not work or even exists as an option.
What I need to do is this:
On Cron > If content type is event and the end date has passed the current date then change the status field from Active to Ended. (select list)
I was able to do this by using the Event: Content is viewed but I really need to to work when cron is ran.
Side note: with the current version I have (Content is viewed) it does change Active to Ended but it also for some reason deletes the title of the node which is strange becuase the title filed is required by Drupal... any idea wht that is happening?
Not sure if it helps but here is an export of what I have done myself:
{ "rules_event_status" : {
"LABEL" : "Event Status",
"PLUGIN" : "reaction rule",
"ACTIVE" : false,
"REQUIRES" : [ "rules", "php" ],
"ON" : [ "node_view" ],
"IF" : [
{ "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "event" : "event" } } } },
{ "AND" : [] },
{ "php_eval" : { "code" : "\/\/dpm(strtotime($node-\u003Efield_event_date_time[LANGUAGE_NONE][0][\u0027value2\u0027]));\r\nif (time() \u003E strtotime($node-\u003Efield_event_date_time[LANGUAGE_NONE][0][\u0027value2\u0027]))\r\n{\r\n return true;\r\n}" } }
],
"DO" : [
{ "data_set" : { "data" : [ "node:field-event-status" ], "value" : "Ended" } }
]
}
}
Any help is very much appreciated.
Thanks
C
to use any custom fields or fields created by other modules than node, you have to add condition "entity has field" to your rules which will make that field "visible" and accesible for later work
side note: I think you can do the date comparison without php_eval, just add another entity has field condition and create "data comparison" condition. There should be tokens available to your needs
Not sure I fully understand the question: rules can be triggered by cron.
You should be able to get it to run when cron executes by picking the "React on event" attribute of the rule to "System > Cron maintenance tasks are executed".
Am I missing something?