How can I affect the delta parameter value? Where it can be set?
I'm beginner with Drupal but know my way around PHP and other CMS apps e.g. Joomla. I've working on my first drupal module and need to create a module with multiple blocks. I know how to switch based on the $op parameter but the $delta value seems always to be the default value set in the function declaration.
How can I select which block to process and display? Can $delta be set so that when using modules subnavigation is uses delta to switch to another block view?
Thanks in advance.
hook_block() is used for defining a and displaying blocks. You define the delta when you are producing the data for $op='list' this is passed back to the hook when it it is called for $op='view'.
the $delta argument will therefore be whatever you define. If you define the keys in your list array as red, green and blue that is what will be passed if the block is displayed.
Maby looking at the example will help you.
Related
I have a container x, with a Link item y set as display.
How can I access programmatically y if I know x?
I tried: getattr(x, 'default_page', None), but it returns None all the time.
By using getattr you may override plone default behavior regarding how to determinate the default page of an object (item or container).
Content objects in Plone inherit BrowserDefaultMixin, which provides the functionality of getting the default page of a object
The mixin, respectively a utility used by the mixin provides the desired method called getDefaultPage
>>> x = b.getObject()
>>> x.getDefaultPage()
...
This will return the right content object or view depending on the configuration on the object, on the FTI and on the View itself and more.
Have a look at get_default_page for more details.
And even better...
This canonical way of getting the default page, would also have helped finding the issue in your case pretty fast, since the method does certain checks to make sure the passed object provides the right "features". A string would not pass those checks.
default_page = getattr(x, 'default_page', None) is the answer. But make sure you have an object for x.
My mistake was I tried b.getObject().absolute_url() in my query instead of b.getObject().
Is it possible to create a new array in windows workflow? More specifically, in the designer.
I've created a variable of System.Int32[], but when I use it I get a NullReferenceException.
I've tried New Int32(5), and various permutations of Dim - nothing I have tried has worked.
I was able to create the array and pass it as an in/out parameter - this works, however the workflow will need to determine the actual size of the array.
To create and instantiate an array, you have to set a default value to your variable with New Int32(FOO SIZE){} or use an Assign activity to instantiate it with the correct size in runtime
You can also use List(Of T) or any other .NET collection structure to achieve dynamic size.
Note that the value must be the right part of a set expression. So, you can google how to do it in VB.NET and you will be fine.
I assume that if you are creating the array in the designer, as you stated, it is either a workflow variable or a workflow argument. The "WF" way to do this would be to use the "Default Value" column under the "Variables" and/or "Arguments" tab.
If it is an argument then the Default Value column only works if the Direction is "In". If your argument is a property, or an Out, or In/Out direction then you would have to use the method mentioned by Davi.
If you are creating it under the "Variables" tag then using the Default value column would be the more built-in approach. The syntax in the default column would be the same syntax mentioned by Davi: New Int32(FOO SIZE) {}
In Archetypes, in order to move a field from a fieldset (or schemata) to another, we can do the following:
schema['creators'].schemata = 'default'
However, I'm not achieving the same using Dexterity. I've tried using form hints. Ex:
form.fieldset('default',
fields=['creators']
)
I notice that it doesn't work because the field "creators" is unknown at this time. (The ownership behavior wasn't evaluated yet).
Nevertheless, with form hints, I can move from "default" to another (eg. "ownership").
myfile = NamedFile(title=_(u"A file"))
form.fieldset('ownership', fields=['myfile'])
How can I do that? Writing my own behavior?
Thx!
You likely need to make the define the field you want to assign on an interface under your control. While this seems duplicative, it is a good idea for purposes of being complete and explicit. You can either:
(1) Declare 'creators' field on your content type interface (likely, recommended solution), or...
(2) Use your own behavior as documented here (and adding this behavior to the type's FTI in portal_types and associated setup XML): http://docs.plone.org/external/plone.app.dexterity/docs/behaviors/creating-and-registering-behaviors.html
The first solution should be the easiest. Any fields that you wish to control fieldset location or order of should likely be defined by your interfaces anyway.
I have a Panel page, which I have given a path of: books/travel-books/%city/%country/%page. The help text underneath the field says "The URL path to get to this page. You may create named placeholders for variable parts of the path by using %name for required elements and !name for optional elements. For example: "node/%node/foo", "forum/%forum" or "dashboard/!input". These named placeholders can be turned into contexts on the arguments form.", so I have named my arguments appropriately.
So now in my code, I need to get the values of those arguments. I've seen arg(0), but that requires me knowing which index the argument has. Is there anyway to access it by the name I gave it in the path? Something like arg('city')??
The reason being, that I need to have similar path arguments on many pages, and need to access the values of these in my module. But the arguments may be in different places for another page. For instance, another page might be at: flights/%city/%country. Then I want to access the city argument within the same function, but it is at a different index.
Can anyone help?
you can check for arg(0) first, see whether it is 'books', 'flights', whatever... then associate names accordingly. do it as a helper function in a custom module and call it before referencing (wherever you're referencing it).
The text that you quoted from the panels help text is referring to what panels call context.
Panels
Panels has a great use if you want to aware of what context a certain piece of content is being viewed. Fx if you had several shops with different products, you might want to control which blocks in a sidebar would be displayed, based on the shop that the product belonged to.
This is essential what context is in panels and what the named placeholdes are used for. You can be default add different kinds of context, fx nodes, users, taxonomy terms. You can then use the different pieces of context if various ways.
If panels default options is not enough, you can also create your own plugins to panels to make it handle your special cases. But it requires a lot of time to learn how panels work.
Other solutions
Using panels might not be the easiest option for you, it depends what you are aiming for. But if you don't need to make pages that is aware of the context, this would probably be a lot easier to do with views and theming. Views can handle arguments in urls very well, and it is a lot simpler to both style and configure.
In Drupal 7 you can get the arguments from hook_content_type_render
function <your plugin name>_content_type_render($subtype, $conf, $panel_args, $context) {
$block = new StdClass;
$block->title = t('test');
$block->content = 'test panel arg: '.$panel_args[0];
return $block;
}
Custom panel tutorial
Anyone knows how to pass multiple arguments from Panels into a view in Drupal 6?
Edit: I know how to pass one argument from Panels into Views, but not multiple arguments.
In the panels argument field, separate them with a "/"
Something like arg1/arg2/arg3
The main thing is to save your view as a panel pane. Good instructions here
In your tutorial you use site.ru/% path for panel, so this means that you use the variable % as argument. If you write site.ru/%1/%2, you can use two argument's variable %1 and %2.