Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have contexts that happen to both be set on certain pages on the site. The first context enables about 7 blocks, the other enables 1 block. On the shared pages, the 1 block shows in the middle of the seven. Is there a way to weight contexts so the blocks show up ordered?
Comment | File | Size | Author |
---|---|---|---|
#14 | context-editor.png | 314.46 KB | stevenmhouse |
Comments
Comment #1
Steven Jones CreditAttribution: Steven Jones commentedContexts are ordered alphabetically and blocks should be being ordered by weight, export your contexts to see the explicit weights of the blocks.
Comment #2
mstef CreditAttribution: mstef commentedAnd that the weights are changed via the regular block admin interface, because there's no way to weight them across multiple contexts?
Comment #3
Steven Jones CreditAttribution: Steven Jones commentedUse the weights in exported contexts. There is no UI to do this.
Comment #4
mstef CreditAttribution: mstef commentedOK - Thanks. Might make things annoying when I continue to rebuild/update the feature.
Comment #5
Steven Jones CreditAttribution: Steven Jones commentedIn context 3.x you layout the page 'live' so this isn't really an issue in the latest versions of context.
Comment #6
mstef CreditAttribution: mstef commentedYea I've been meaning to try.
Any idea when 3.x will have a stable release?
Comment #8
aufumy CreditAttribution: aufumy commentedI am using context 3, beta5.
A block I added through /admin/build/block is displaying above the blocks for a context. How can I re-order them?
I am not sure where I can go to layout the page 'live'.
Comment #9
aufumy CreditAttribution: aufumy commentedI ended up excluding the default context block using:
<?php return !count(context_get());?>
from http://drupal.org/node/813954#comment-3043934
And adding the block back in for the particular context, so that it can be re-ordered through the context page.
Comment #10
seanrJust found this - truly awesome.
Comment #11
MattBrigade CreditAttribution: MattBrigade commentedI know this thread is closed, by I thought I would post my workaround in hopes that it might benefit someone. I got around this problem by altering block weights programatically using hook_context_load_alter() (hook defined in the Context API). I set up a small custom module named "context_mods" and called hook_context_load_alter() to change the block weights as needed.
Here's an example from my project (defined in "/sites/all/modules/custom/context_mods/context_mods.module"):
Comment #12
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedtry this patch:
http://drupal.org/node/455908#comment-3609800
Comment #13
waldbeek CreditAttribution: waldbeek commentedComment #14
stevenmhouse CreditAttribution: stevenmhouse commentedAfter reviewing I'd recommend trying this first! I have the 'admin' module installed that provides a lot of ease of access, including to 'Context editor'. I'm using Context 3 and Context Editor is included in Context UI, which comes with Context but is a separate module. Here's how I accomplished what this thread is about.
1. Open the Admin bar via the wrench logo.
2. Click on 'Context editor'
3. Click on the 'edit' button next to the context that you want to alter the block placement for
4. At this point the other context's blocks are greyed out to focus on the blocks provided by the current context.
5. Hover over the block you want to move and an moving icon appears on the upper right corner.
6. Click on this icon and drag to desired place.
7. Click on 'Done' in the Admin bar.
8. Done! SUPER EASY - and also has a bunch of other cool context features
Enjoy!
Comment #15
doublejosh CreditAttribution: doublejosh commentedThat's not the question. It's about blocks across multiple contexts.
Comment #16
Pasqualleblock placement works across multiple contexts.
really cool feature!
please someone create a handbook page for this
Comment #17
doublejosh CreditAttribution: doublejosh commentedMaybe we're talking about a difference between D6 and D7? Can't seem to do it in 6... if I'm just missing it, then +1 for a handbook! :)
Comment #18
Oliver Huynh CreditAttribution: Oliver Huynh commented#14 correctly fixed the issue.
Comment #19
wonder95 CreditAttribution: wonder95 commentedI have Admin module installed with Context 6.x-3.0, but for some reason the Context Editor block doesn't show up when I'm on the Context page, and when it does show up, it only shows one of my four contexts. Is there something I have to do to make it show up with all contexts?
Comment #20
wonder95 CreditAttribution: wonder95 commentedHere's another thing I tried. I have a context that just has one block in a sidebar (and shows up based on another context) I exported the content, modified the weight for the block and re-imported, but the block weight remains unchanged for some reason. Should that change it?
Comment #22
franzHow come the need for an additional module to do such a simple thing can be considered "fixed" ?
Comment #23
hefox CreditAttribution: hefox commented#455908: Allow setting block weight via context admin UI
Comment #24
Prine CreditAttribution: Prine commentedThank you mattbrigade.
#11 did it for me.
Comment #25
thedavidmeister CreditAttribution: thedavidmeister commented#1 did it for me, although I did have to make sure to revert my contexts and clear my cache.
I can confirm that #14 is a feature that is relatively easy to set up with admin however #14 failed to mention that you have to turn the block on in the admin tools settings before it will appear in the wrench menu.
Comment #26
jalake CreditAttribution: jalake commentedSorry for bringing this back from the grave, however when I export a context, edit and then import (either deleting the old context or allowing overwrite) my adjusted weight always gets reset, as Context wants me to save after import.
Am I missing the point of the export? Should I be placing the export code somewhere else instead of editing and importing?
Comment #27
thedavidmeister CreditAttribution: thedavidmeister commentedYou adjust the weight in the code created by Features. I did this like two days ago and it worked fine for me.
When we're talking about exporting a context in this thread we're implying an export through the Features module, not through an import/export UI.
Context will read the code in the Feature and pull the weight from there as long as you don't override it in your database. Using an import/export UI will import the context straight into the database, from where it behaves exactly as any other context would and so the weights will be recalculated.
The important step, whether re-arranging your blocks through the context editor or directly in the Feature itself is to make sure that whatever is in your Feature represents what you want happening in your site.
Comment #28
info@cgfix.com CreditAttribution: info@cgfix.com commentedI think the solution is in each context above the blocks in the region, click on the arrange icon to expose the each block weight drop down. set these to interact with all blocks in that region even other contexts or regular blocks.
Comment #29
general_ludd CreditAttribution: general_ludd commentedI know this is closed, but someone like me is bound to come across this and assume the problem still exists. It is solved with the context editor. It is built-in to the context UI.