So I have installed a module that gives me a (marque) block.
I can use this block and add it to my website and it works.
But what I want to do is to change the content of the block with a title of a content type.
So instead of:
Marque block: plain text
I want
Marque block: Title emergency messages, if expire date is < now
How can I do this?
Can I get that installed block inside the View of the emergency messages?
Thanks in advance!
You can modify the title of a block by using the hook_block_view_alter(&$data, $block); hook in your custom module.
See the documentation here.
Related
I created a custom block, and I faced the issue I've never faced with before. After saving the block and realoding the page, I can see the block disabled and with a warning
This block contains unexpected or invalid content.
And in the console I can see this:
Block validation: Block validation failed
Content generated by 'save' function:
{here is a layout without any value from attributes}
Content retrieved from post body:
{here is a layout with all the data}
So when I log the attributes inside save function they are empty, and WP marks as an error, when the content from the save function does not match to the content posted to the server. Does anyone have any ideas?
When registering a block in JS I forgot to add attributes with selectors. When added, block start working.
I am using DotLiquid for the template. I am working themes same as Shopify. I am facing an issue like I am not able to load 'section' tags. How to render the section tag values. I have 'product.liquid' template inside I am using {% section 'product-template' %}. I am getting the error "[SyntaxException: Unknown tag 'section']". Can anyone please help me out. How to fix this issue.
You can look at the DotLiquid source on github
You'll see section is not registered as a tag. You might be able to prompt one of the maintainers to add it but otherwise you could clone the source and add it yourself.
Basically I created a webform and enabled it as a block, now I want to put that block inside a specific node. I can do that by placing it in a 'content' region and defining the specific node BUT it displays at the end of the content. Now how can I move it between specific elements inside the content?
The node is using a page-type....tpl.php which is used by 5 other nodes as well so I cannot change the code.
To visualize it looks like:
[ content ]
-description text-
-list of videos-
[ end of content ]
and I need to put my webform between the text and the video list. Is there a way?
There are many roads you could take, but since you said you're considering the template file: Why not use a node-specific template, since page is a node type?
Say you're on node/123, then you could use a template named node--123.tpl.php
(see Drupal 7 Template (Theme Hook) Suggestions) and embed your block right there.
Alternatively, you could provide a reusable token in a custom module via hook_token_info and combine it with the commonly used token_filter module. But that might be over the top, if it's just one node you need to touch.
For Drupal 7 a bit of a hacky way to display the contents of a block in content would be to enable the PHP Filter module. Then edit your node and switch to the PHP code Text format and add this code
<?php
$block = module_invoke('block', 'block_view', '1');
print render($block['content']);
?>
where '1' is the block id found in the URL when you edit the block and be sure to include the PHP tags.
Also see this page https://www.drupal.org/node/26502 for more information on placing blocks.
You can use the EVA module to add the webforms in the node as a field.
You basically create a view and choose the "eva field" option then you make sure that this view selects only the webforms you want to have and relates it to the node (the EVA module documentation has much better examples than I can provide).
After you have added it as a field you can place it anywhere in the node.
There is also the Block reference module that could help you.
I use my custom block for displaying a flash game at the front page of my Drupal 7 installation, but there is also the annoying message:
<div id="first-time"><p>No front page content has been created yet.</p>
<div class="item-list"><ul><li class="first last">
Add new content</li>
</ul></div></div>
below it and I can't remove it. Is there please a hook for adding custom CSS? In my module I would like to make the #first-time light grey or invisible.
I prefer not to add a blank content just to get rid of that text.
Thank you!
Alex
UPDATE:
I've added the following to my module:
function game_init() {
drupal_set_message('XXX init called XXX');
if (drupal_is_front_page()) {
drupal_add_css('#first-time {color: green;}', 'inline');
}
}
but don't see that CSS-code or XXX string inside my front page.
UPDATE2:
Oh, I had to clear the cache and now it works (the Drupal docs seem to be wrong here - there was written that 'inline' CSS is not cached...)
Hiding the CSS is the WRONG way of doing it. why did you created your content as a Custom Block?
you should create a "Page" and set this page as front page in the Configuration->Site Information.
Whatever. you can also use any of these options but is not recommended.
you can also also add a BlankPage by Adding only the Title(then hiding it in PHP on page.tpl.php)
you can add your css in /templates/themes/bartik.info
you can call drupal_add_css on the _init() hook of your custom module.
Blocks are used to display information in every page(although we can set to display only on certain pages). Say For Example. A Menu, or A Shopping Cart etc.
If you want to add some CSS for a module, you should use drupal_add_css()
Why not simply add this CSS to your theme?
i have add my region to a info file:
regions[mine] = Mine
then i have created a view with a block display and I add this block to my custom region.
Last, I invoke in my node.tpl.php with:
print render(block_get_blocks_by_region('mine'));
but I have a blank page with html:
Please any help??!!
Why are you invoking that in your node.tpl.php file? This doesn't make any sense in the context. It appears that you want to have a block inside of a region - this is configured in the administration pages, not theme files.
If you are getting a totally blank html page rendered then you likely have an error in your PHP somewhere - Drupal has a habit of swallowing PHP errors without any visible warnings.