Easyadmin : display tooltip in index page - symfony

Is there anyway to add tooltip functionality to easyadmin 'index' page?
In documentation, the sethelp function can be used only in the 'detail', 'edit' and 'new' pages.

Related

Selecting an Elementor template using WordPress REST api

To select a template through the Wordpress REST api you normally assign the 'template' key a value. However, you don't appear to be able to select specific Elementor templates the same way. That is to say, the error only gives "elementor_canvas" and "elementor_header_footer" as options next to Wordpress defaults.
If I wanted to assign Elementor’s Full Width Page Template to a post, is there a way to do this via the Wordpress REST api or programmatically via a workaround?
def create_page(title):
post = {
'title' : title,
'status' : 'publish',
'template' : 'elementor_canvas'
}
response = requests.post(url + '/pages', headers=header, json=post)
A workaround involves creating an Elementor template then using the sortcode as the content of the post e.g.
def create_page(title):
post = {
'title' : title,
'status' : 'publish',
'content' : '[elementor-template id="1159"]'
}

How can I add a paragraph (as default) in the node form by using hook_form_alter in Drupal 8?

I am trying to add a bunch of different empty paragraphs of different types, to a entity reference revisions field, everytime a node of a certain content type is created.
I DON'T want to use the contrib module "default paragraphs" for this, because I need to use a certain form widget here, and default paragraphs is also achieved by a widget.
What I tried so far:
function myModule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
$paragraph = \Drupal\paragraphs\Entity\Paragraph::create([
'type' => 'tab_features'
]);
$paragraph->save();
$form['field_tabs']['widget'][0]['target_id']=$paragraph->id();
$form['field_tabs']['widget'][0]['target_revision_id']=$paragraph->getRevisionId();
return $form;
}
$field_tabs is my entity reference revisions field.
'tab_features' is the paragraphs type I want to add.
I guess there should be a method that can be used in the form or form widget to add a paragraph to the form, like someone already clicked the button to add it. I want to avoid to actually trigger this via Javascript if possible. Anybody knows how to do this in form_alter?
In a project I'm working on, we have done something like this:
//get the body field
$field = $entity->get('field_em_p_body');
$paragraph = Paragraph::create([
'type' => 'em_section', // Paragraph type.
]);
$paragraph->isNew();
$paragraph->set('YOUR_FIELD', 'SOMETHING');
$field->appendItem($paragraph);

How to configure a Sonata Field Type outside of the Sonata Admin in a Symfony2 Form Class?

Use case:
After using sonata_type_model_list outside of Sonata Admin*, I want to show the same display as in the admin as the following:
However when I add my field to my method buildForm like this:
[...]
->add('position', 'sonata_type_model_list', array(
'model_manager' => $categoryAdmin->getModelManager(),
))
[...]
my field looks like that :
Does someone know how to configure the field to get this display outside of the Sonata Admin?
* See my previous question/use case with title "How to use sonata_type_model_list outside of Sonata Admin?"

wordpress onclick AJAX load specific post type with specific custom field

it's my first post here on stackoverflow after finding help for tons of questions- Thank you so far.
I'm building a wordpresstheme within Wordpress 3.0.4.
Theres's a navigation: Home | comedy | scifi | action | arthouse
I have set up some custom post types like "reviews".
Taxonomy = films
slugs = comedy, scifi, action, arthouse
I also added the possibility to acitivate a custom field "feature" inside every post.
On the front end startpage all posts from custom post type "reviews" are shown.
Now theres a button "featured" - when see visitor clicks that button, only posts with customfield "featured" shall be shown.
The content should be loaded with AJAX.
I know how to load stuff with AJAX from another page inside wordpress.
E.g.: I'm using:
<script type="text/javascript">
$(document).ready(function(){
$.ajaxSetup({cache:false});
$("#featured a").click(function(){
var post_id = $(this).attr("rel")
$(".wrapper").html("loading...");
$(".wrapper").load(jQuery(this).attr("href") + " .wrapper")
return false;
});
});
</script>
so when someone click the button "featured" ajax loads a .wrapper part from another page:
<?php
query_posts( array(
'post_type' => 'reviews',
'taxonomy' => 'films',
'meta_key' => 'featured',
'meta_value' => 'yes',
'posts_per_page' => 10
));
?>
so the query is kind of "fake filtered". But that only works for one slug/category e.g. "arthouse" not dynamically.
When the visitor goes to a specific page e.g. "arthouse" - only posts of custom post type films are shown with slug "arthouse".
Using this query:
<?php query_posts('films=arthouse'); ?>
Now the question: How can I get wordpress to understand, that "onclick" the featured button only the posts with "featured" = "yes" are shown inside the slug "arthouse"?
Is there some js filter I could use? GET handler? Or what would be the right way?
I really appreciate some help!
thank you!
ad
But how can I make something happen with just a click?
Is there a way to let jquery handle a php query?
I know how to query posts with more than one taxonomy like in this post here: https://wordpress.stackexchange.com/questions/7107/how-to-filter-custom-posts-by-tags-and-custom-fields
but how can I do it with ajax - without a pagereload? Like this somehow:
http://www.wpthemetoolset.com/filterable/#all
thank you very much!!!
AD

Drupal: Dynamic View using Arguments

For a current project i need to setup a specific view to display a gallery detailpage. It should work like this:
1. User clicked a node (costum-post-type: gallery)
2. User received an overview page with linked images
3. User clicked an image
4. User received the gallery page (gallerific view)
Step 1-3 are done. But how can I get Drupal to build a detail page using the data of the overview page?
For Example something like this: http://example.com/gallery-1/detail or http://example.com/gallery-2/detail.
/gallery-n is the overview page with linked images and detail is the detailpage of /gallery-n.
Hope you'll understand what i mean?!
EDIT
On the overview page i have a bunch of thumbails which each are linked to the detail gallery (jquery galleriffic) page.
If I'm correct understand your problem you should do this things.
1. Create view1 for page with linked images. It should be page display with http://example.com/images/%nid
where %nid is nid argument of gallery.
2. Create view2 for gallery detailed page. it should be page display with http://example.com/%nid/detail
3. Theme that views as you want.
4. For view1 for image field use override output in field settings to make it links to %nid/detail
P.S. Use relationships where needed. If description is not clear, fill free to ask.
You can try something like this, in a custom module you make (or maybe already have):
where you set the path to the page you want in the menu and set it as a callback that calls a function and then you can render whatever you want, or call whatever you want.
function MODULENAME_menu() {
$items = array();
$items['gallery/%/detail'] = array(
'title' => 'Gallery Detail',
'page callback' => 'MODULENAME_gallery_detail_page',
'page arguments' => array(1),
'access callback' => TRUE,
'type' => MENU_CALLBACK
);
return $items;
}
function MODULENAME_gallery_detail_page($gallery_id) {
// Here you can render the view as a page, using the gallery
// id which you passed as a parameter to this function.
// So Change MYCUSTOMVIEW to the view you want to render
$view = views_get_view('MYCUSTOMVIEW');
print views_build_view('page', $view, array(), false, false);
}
Just change MODULENAME with the name of your module. You might need to do some work when calling the views_build_view, but it should be a start, you can ask some more questions if you like and I'll help out.

Resources