Way to browse pages from particular location in PageChooserBlock, like browse "sub pages or same level pages" from current editing page in which this block is used. I observed that when any page is selected in PageChooserBlock then browsing starts from the same current selected page. I wanted to start default browsing from current edting page (in which this PageChooserBlock block is used) if no page is already selected. Is there any way to do it? I googled for some way or direction for doing it but no success. I also checked chooser hook but there is no way to get current editing page in this hook. So can't use it. Also tried to search in source code of PageChooserBlock for such possibility but no success for me or may be I missed the possible way. Your help is appreciated.
Wagtail set default page explorer view location for PageChooserBlock in admin
483 views Asked by Nei At
2
There are 2 answers
0
Nei
On
I am able to achive the expected result using suggestion of @rgs258 with some modifications done in JavaScript. I subclassed AdminPageChooser and implemented media method and added some sort of hack for getting pageid of editing page as below in JavaScript. I think(know) this is not the perfect way but at least I am able to achive my expected result. Please suggest if there is any better way to do it.
I created new JavaScript file with the below coad and added it in newly implemented media method after page-chooser.js
if(typeof createPageChooser === 'function'){
let originalCreatePageChooser = createPageChooser;
createPageChooser = function(id, pageTypes, openAtParentId, canChooseRoot, userPerms){
if (!openAtParentId){
let path = window.location.pathname;
openAtParentId = path.replace('/admin/pages/', '').replace('/edit/', ''); //Know it is not the best way but ...
}
originalCreatePageChooser(id, pageTypes, openAtParentId, canChooseRoot, userPerms);
}
}
Related Questions in PYTHON
- How to store a date/time in sqlite (or something similar to a date)
- Instagrapi recently showing HTTPError and UnknownError
- How to Retrieve Data from an MySQL Database and Display it in a GUI?
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Python Geopandas unable to convert latitude longitude to points
- Influence of Unused FFN on Model Accuracy in PyTorch
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Conda has two different python binarys (python and python3) with the same version for a single environment. Why?
- Problem with add new attribute in table with BOTO3 on python
- Can't install packages in python conda environment
- Setting diagonal of a matrix to zero
- List of numbers converted to list of strings to iterate over it. But receiving TypeError messages
- Basic Python Question: Shortening If Statements
- Python and regex, can't understand why some words are left out of the match
Related Questions in DJANGO
- Django Admin Panel and Sub URLs Returning 404 Error on Deployment
- How to return HTTP Get request response from models class in Django project
- Issue with Quantity Increment in Django E-commerce Cart
- Can't install Pipenv on Windows
- use dict from python in django html template and also in js
- 'pyodbc.Cursor' object has no attribute 'callproc', mssql with django
- Django socketio process
- Root path analogue in uWSGI as in Uvicorn
- Django - ModuleNotFoundError: No module named 'backend'
- Does Python being a loosely typed programming language make it less secure?
- sorl-thumbnail adds a background color when padding is used
- Can't connect to local postgresql server from my docker container
- Why ProductHunt api dont work with Python?
- why i have to put extra space in before write option selected because it show error if i don't ' option:selected'
- Django Arrayfield migration to cloud sql (Postgresql) not creating the column
Related Questions in CONTENT-MANAGEMENT-SYSTEM
- Check REQUEST_URI for any /nl/ or /en/ to change my RewriteRules
- Website Architecture and programming language
- what is best frontend and backend tools to build management sites with the support of cross domain communication
- Joomla 5..0.3 delay in search
- Model attributes in the custom component controller of accelerator - How this is handled in the context of OCC and Spartacus?
- File manager for Ghost CMS
- Contentful UI extension to intercept unpublishing
- Multi layout column form in Optimizely CMS
- x icon disappears in Webflow
- The media files are not visible within the components when using Strapi API
- How to create a table of contents from Strapi rich text field
- I am getting issues with vtiger the open source crm, was working fine but now when i try to configure mailbox it loads foever doesnt work
- Next.js 14 Draft Mode not working in an iframe(headless CMS preview)
- Parent menu link opens children when clicked, instead of going to link (Drupal)
- Strapi CMS deployment external database supabase, managing content with Nuxt and images on Cloudinary
Related Questions in WAGTAIL-STREAMFIELD
- Why does the ImageGalleryBlock in wagtail-crx/coderedcms return no images?
- How to add custom js for select in Wagtail choice block
- Wagtail rich text block better revision diffing
- Wagtail publish images programatically doesn't reflect in FE
- How can I restrict the images selectable by the user in Wagtail's ImageChooserBlock?
- How can I programmatically create a Page in wagtail with stream field
- In Wagtail how can I access the Page object from inside the StructBlock template?
- Is there any way to recover Streamfield data that was lost due to lack of migration?
- Any way to use CRUD in Wagtail(Django) without reload page?
- Renaming Wagtail StreamField
- How to Disable Certain Block Types in Wagtail's StreamField Based on Selected Theme?
- Unable to get formFields from callable ChoiceBlock in StreamField
- How to avoid wagtail nested rendering in the admin panel?
- How to edit a Table Block of wagtail page and save to the DB
- Wagtall - template class for blocks StreamField
Related Questions in WAGTAIL-ADMIN
- Difficulty with hosting Multilingual Wagtail site on alwaysdata
- Problems deploying Wagtail 6
- Using Wagtail's rich text widget for simple form?
- Account language setting ignored in Wagtail admin for localized model names
- How to add custom js for select in Wagtail choice block
- Wagtail rich text block better revision diffing
- How to default the external link tab in RichTextBlock link modal in Wagtail admin?
- Is it possible to specify errors for individual InlinePanel items?
- Customizing Wagtail Admin List View for Page Model: Adding Filters
- why is unable to import the ImageChooserPanel from wagtail.image.edit_handlers
- How to hide the Page tab in the wagtail admin dashboard?
- Is it bad practice to create wagtail page only for organizational purposes?
- Wagtail modeladmin-snippets migration
- Making different panels for createview and editview
- wagtail.search.backends.base.OrderByFieldError: Cannot sort search results with field "page_ptr". Please add index.FilterField('page_ptr') to Model
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
I've not done exactly what you seek to do, but I think you may want to subclass AdminPageChooser and implement render_js_init in order to define a default
parentof your choosing.You can then subclass
PageChooserBlockand implementwidgetin order to return an instance of your subclass ofAdminPageChooser.I gave this a quick go and it seemed to work.