Define block delta from a renderable array via hook_page_alter - drupal-7

I am working at theme layer via hook_page_alter to insert a custom "special_theme" into the footer region without using block management, nor module:
$page['footer'][] = array(
'#weight' => 10,
'#theme' => 'special_theme',
'#theme_wrappers' => array('block'),
'#region' => 'footer',
);
The template is defined at hook_theme. The block is inserted into the footer region as I expected, but I need to define its block id or delta. Drupal automatically inserted id="block--2". I need to change "--2" into more readable delta, such as "special_delta".
Is it possible with current drupal 7, and how?
I may miss something obvious. Thanks for any help.

This is not possible with current drupal 7, I guess. Hopefully future drupal can define blocks via template layer. The hook_page_alter is already powerful. How can I close this question?

Related

Drupal 7 Taxonomy Multiselect box size

I have couple of taxonomies that have few hundred terms in. A content type has multiple of these taxonomy multiselect boxes.
Problem is, that select box size is about 5 (so it shows only 5 at the time). How can i increase the size? Because now treelike use is impossible, because you won't see parent after you've scrolled a bit back.
The problem is in the admin / editor view, and are not related to end-user.
If it's really about the height of that select box, why don't you add it via CSS?
#your-form-id .form-select[multiple] {
height: 300px;
}
Alternatively, implement hook_form_alter in your module:
<?php
function YOURMODULE_form_alter(&$form, &$form_state, $form_id) {
$form['YOURFIELD']['#size'] = 30;
}
?>
Have you tried any of these?
https://drupal.org/project/term_reference_tree
https://drupal.org/project/hierarchical_select
https://drupal.org/project/multiselect
edit - ah ok I'll explain:
OP asked a question about changing sizes of select boxes because there were hundreds of options available and hinted at hierarchy issues in their post. The above modules provide more rich interfaces for users to select multiple options, hence why I listed them. I shall explain more next time soz!

In Drupal 7, how do I make a block visible on the user view page, but invisible on the user edit page?

In Drupal 7, I have added a block to the Content region of the User page. I did this by specifying
user/*
in the Visibility Settings -> Pages -> Show block on specific pages -> Only the listed pages setting.
However, because the wildcard accepts anything, now the block appears on the User's edit page.
Is there a single number wildcard, like
user/%integer
that I can use here so that the block only appears on the User view page?
How can I hide this block on the User edit page in Drupal 7?
You can try enable PHP filter module, so that you can enter php on Block visibility settings page.
There you can check for argument like
<?php
if(arg(0) == 'user' && arg(2) != 'edit' )
return true;
else
return false
?>
These days there is another alternative available ... which doesn't require the PHP filter to be enabled (which you should try to avoid whenever possible) ... Just use the Rules block visibility module. Here is a quote from its project page:
The Rules block visibility module allows Rules components to be used to control block visibility. This provides Drupal administrators and developers extreme flexibility in controlling when blocks should be displayed on their websites, in addition to the default visibility options provided by Drupal.
The general idea is that if you can do it with Rules, you can use it to control block visibility, so the possibilities are limitless.
Need to show a block only for users registered more than a month ago?
Perhaps you have a block that must be shown only between 8am-5pm on weekdays?
What about displaying or hiding a block based on current weather conditions?
All of this can be done by using Rules block visibility.
With that, and as per the "if you can do it with Rules, you can use it to control block visibility" above, you've reduced your question to making Rules intercept the situation where someone uses an URL like /user/*/edit (replace * here with any allowed value for uid). If you're not familiar with how to do that with Rules, then have a look at my answer to the question "How to make the permissions of a module more granular?" (and pay attention to the regex-expression included in the sample rule I included there).

How to move content to drupal 7 region?

I have created a region named "footer" in my drupal 7 template.
I have created a content type named "footer-article".
I have created a block called "footer-block".
What I want to do is:
whenever I create an article of "footer-article" content type
I want it to automatically reside in the "footer" region in all of my pages/ or some of the pages?
What is the most efficient and simplest way to do it?
because I was thinking that I always need to create new blocks and put article inside this block in order for me to position it in my desired region?
I am a newbie in drupal 7
Thanks for your help.
Install the views module. Always install the views module.
http://drupal.org/project/views
It will allow you to make a list of a content type, which you can then export as a block and add to your region. This will automatically update the block when ever you add a new "footer-article".
You can set the view to show full posts, teasers or certain fields.
It's the best module for Drupal in my opinion and is a must have for any Drupal sites.

CakePHP - What is the best approach to create an Admin Section

I am looking for an insight into the best approach to create an administrator section in CakePHP. I've looked at plugins like BrowniePHP as well as others, but I am not entirely satisfied with using plugins. So I am trying to create my own which will encompass the things I need. I;ve looked at some tutorials, but cant find the right answer.
I am currently creating a vast application, which is about 10% done, but I now feel the need to have an admin section before moving on.
Basically I would like a section where I can add new articles, approve comments, deny user access, etc. This section should only be accessible by an administrator.
Also, this administrator section must be able to save to any other model.
I am still learning CakePHP and any detailed instruction would be appreciated.
to create an admin-section the first thing you have to do is to manually edit the core.php within /app/config and write the setting Routing.prefixes. This line should be around line 88 somewhere and you just have to uncomment it.
In case you can't find it, it should look like this:
Configure::write('Routing.prefixes', array('admin'));
So now you can write your admin-functions within your controllers like this:
function admin_edit($id = null) {
//your admin function
}
You don't need access to every model since your writing these function within your controllers like every other "normal" action.
You just have to connect a route to handle the admin-actions:
Router::connect('/admin/:controller/:action/*', array('admin' => true, 'prefix' => 'admin', 'controller' => 'pages'));
// 'admin' => true is a variable for you so you can check if it's an admin-action which is requested
// 'prefix' => 'admin' means that you can write function with this prefix like above
You can then access these actions via the url http://yourapp.com/admin/controller/action
If you now use the Auth-Component you can write methods for checking if a user is allowed to access these methods.
For further information please read these manual-entrys:
Prefix-Routing
Authentication (Auth-Component)

How can I change the names of the tables that are shown in brownie plugin menu (cakePhp)

I am working with brownie plugin for cakephp and I would like to know if it is possible to change the names that the CMS show in the menu. By default it takes the name of the database tables, but I want to change the name only to display it in brownie, no modify the table name.
Is any configuration in $brwConfig that changes the name, something like
'fields' => array(
'names' => array('name'=>'new name'),
),
No, it doesn't look like that is the case. Looking at the app_controller for the project, the _menuConfig() function doesn't reference any external configurations when it creates the menu.
If you really want changes, you'd have to modify the plugin to my understanding - there is no way to override specific functions from your main app.

Resources