How do I get access to current edited entity data like id and guid in modal window of 2sxc DNN module? - dotnetnuke

I'm writing my custom property type for module 2sxc. I mean I'd added a js file inside my app at path "/system/field-string-my-custom-field/index.js" and I'm writing my code there.
And I need to get id (or guid) and entity type of a current edited/created entity in modal window. I didn't find neither id, nor guid of that entity. The only place I've noticed in the html inside iframe that could tell type of entity is title on top of modal window, but that's also not good to take it from there, since it's actually a label, not the name of the entity, which might be different from the actual entity name. When I checked the code that is executed on submit button click - it has object formBuilderRef, which contains all the listed data I need (current entity's id, guid, type). But I didn't succeed in accessing it from my code for now.
Additional info:
I'm creating a custom property like this one. So on editing entity with my custom property type there's this modal window. Modal image is from internet but it should be enough to get an idea.
iframe's src property contains EntityId, but it looks like a bad place to take id from, since it contains an id of the entity used to open modal window of 2sxc module, but I could go to app settings and start editing totally different entity that is not on a current page at all. So I need an id of that currently edited entity and correct type, not a label.
So how do I get the data I need from there?

You can get them on
context.target.entity.id and context.target.entity.guid
see also: https://docs.2sxc.org/js-code/edit-form/formulas/context.html
while developing formulas, it's best to also watch the console, because on test-runs it will output all relevant objects data and context to the console.

Related

Is there a way to add other columns to the list display in the page admin?

Currently, in the wagtail admin for a page, it lists the Order, Title, Updated, Page Type, and Status. I would like to add an extra column for a property from my custom page model.
I would have thought that if there isn't a built-in method, I could at least overextend a template, or simply append something to the page title?
My situation is that I have created a blog page that has a date field. It is only that I wish to show.
My google-fu has failed me entirely on finding an answer as I'm sure this must have been discussed before.
There isn't currently an 'official' way for customising the columns in the listing. However, for displaying the date alongside the page title, you could make use of the get_admin_display_title method added in Wagtail 1.8: http://docs.wagtail.io/en/latest/reference/pages/model_reference.html#wagtail.wagtailcore.models.Page.get_admin_display_title

Is there any way to force "View as Visitor Group" to show in edit mode?

The "View as Visitor Group" option only shows in the EPiServer editor when there is content for visitor groups added to the rich text areas. If you have code based customisations then this makes it hard to preview your changes.
Is it possible to trigger this to show all the time or based on some decision in code?
Currently the workaround is to temporarily add some visitor group content to a text area, save & view, then "View as Visitor Group", then delete the temporary content in the text area before saving which isn't ideal.
This is EPiServer 6R2 (aka 6.1)
Original question: http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=74864 (lifeless forum, ugh). Posted here as I also want to know the answer as I'm working on similar functionality to the original author.
There is an interface IPersonalizedRoles that makes the View as visitor group menu appear if it is implemented on a property. However I think you have to create a custom property to use the interface yourself.
The SDK for the interface: http://world.episerver.com/Documentation/Class-library/?documentId=cms/7/68f4d6ca-e9a5-884d-4ca8-e5431a345112
You implement GetRoles() and return an IEnumerable with the visitor group GUID ID:s that you want to show up in the list.
Maybe you can create a custom dummy property and return your groups there?

Panel Pane visibility rule based on users in entity reference field

I have a content type called 'company' with an entity reference field called 'company_managers' referencing users who will be allowed to add and edit other content types relating to this company.
The company node is displayed using panels. What I am struggling with is to create a visibility rule which will only show a panel-pane if the logged in user is referenced in the entity field 'company_managers' this will allow me to show panel panes specific to users in the 'company_managers' field.
So the psudo logic for the visibility rule would be:
Check if logged in user is contained in 'company_managers'
If yes show panel-pane
if no
dont show pane.
This seems such a simple use case that i dont want to create custom code it must be achievable 'out the box' I just cant seem to get to the answer. So after two days of researching am asking for help.
NOTE: have spoofed this behavior using the visibility rule content manager and manually selecting a user on this site. All I would need is to put in the logged in user but I dont think you can put in dynamic variables or tokens.
Help much appreciated.

how to use view ticker in drupal

Does anyone explain me how I can use Views Ticker.I loaded modul but no idea how I should use it.please explain me step by step ,I am new on drupal
thank you.I wanna do somethink like this link
enter link description here
Create a "content type" and name it anything in my own case I will name it "news"
To create a content type, navigate to administration->structure->Content type-> add content type
You can add new fields to the content type if you wish. But in my own case I will just use the default settings, since I need only the titles to appear as flash news headlines so click "save"
Next create a new view and name it anything in my own case I will call it "headlines"
To create a new view navigate to administration->structure->views->add new view,
Now setup the new view with the following attribiutes; {View Name = headlines, show = content, of type = news, sort by = Newest First, create a page = uncheck, display format = Views Ticker, of = Titles (Linked)", use a pager = unchecked, create a block = checked} now click save and exit
Next navigate to Blocks and enable the block we just created through the views. Check for the block name "headlines" and specify the location where you will like to place the newly added block and save.
To enable the block navigate to Administration->Structure->Blocks
Now Navigate to view and select the new view we just added. In my own case it is called "headlines" and make sure "Format" is set to View Ticker, you can customize the settings of the View Tick by click settings.
Next add a news content type using the content type we just created. Add a title, a summary and a content. Then hit save
To add a news content type, navigate to Add content
Tip: Add at least two news contents in other to see the full effect of the view ticker
There is "Some" documentation in the readme file. check it out and see if it fits your requirements, http://drupalcode.org/project/views_ticker.git/blob/refs/heads/7.x-2.x:/README.txt
From first glance it seems like a views plugin so you could probably try changing the dispaly in the views settings.
Yes, you need to create a new View that pulls in some kind of content (i.e. Announcements). Under the "Display Format" when creating the View, you'll see an option of "Views Ticker", if you've installed the module correctly.
Based on the example you pointed to, you'll probably want to create a Block at the same time, that you can insert into the desired region.
Once you've created the View, you'll see a link for the Display Format "Settings". This is where you choose whether to make it scroll horizontally, vertically, speed, etc.
Once you updated and saved the view, you should go Admin > Structure > Blocks and insert your newly-made Views Ticker block into one of the regions (regions available will vary based on your Theme).
Then, as long as your permissions are correct, and you have actual content,you should see the scrolling ticker show up on the page(s) where the block shows up.
To use views ticker, it needs you to have an view which outputs some data.
I assume you have such a view. Then go to that view's edit page and set format to views ticker. You should have enabled views ticker module to get that option to formats list.
Then it will show you the settings window, in which you can set settings such as vertically, horizontally, BBC, etc styles for your data movement and respective speed etc.
After you did, click on apply button and then save button top of the view's edit page.
If all goes well it should display moving contents in the page/block related to that view.

Inline add/edit/delete data in views in Drupal 7

I am trying to create a content type (say Meter). Each Meter consists of a "Meter Reading". This meter reading content contains three fields, say title, date range and usage. I have a Panel page where I display all the Meter Readings related to a parent Meter. I have displayed the Meter Readings in a tabular format.
I want the user to be able to add new Meter Readings without going to the default Meter Readings creation page. Rather than the default form kind of page, the user should be able to enter the data in the table view provided and it should be automatically saved into the project itself.
So, I want the functionality to be like:-
Display all the meter readings with two links, i.e., Edit and Delete,
When the user clicks on Edit link, the meter reading row should become editable and the user should be able to make the changes inline in the same table,
In the footer there should be a link for adding a new meter reading and when the user clicks on it, a new blank row should be added dynamically to the table and the user should be able to make a new entry into it.
Is there a module in Drupal 7 for doing so?? I have already tried out several modules for this such as SlickGrid, jQGrid and jEditable
Any help would be great. Thanks in advance.
Am afraid am not aware about a module that does all that out of the box. But in case you carry on with custom coding you can have a look at the following:
Edit and Delete options per row in views
Use Views Megarow. For working example you can have a look at how its used in commerce backoffice. Please note that you need to write the form structure ( FORM api ) for the quick edit form in a custom module. The Views Megarow takes care of ajax populating the edit form, its submission in client side, and refreshing the original row after the response from server.
When the user clicks on Edit link, the meter reading row should become editable and the user should be able to make the changes inline
in the same table.
Views Megarow doesn't support inline editing. But another module as suggested by #nmc does it. Its editablefields. But it doesn't have any edit/delete button. You click on the text directly ( provided user has appropriate permission to edit the field data ) in view.
In case you are going to use editablefields, then you would have to add another delete button in view, which one confirmation would redirect to the page that triggered delete action.
Since delete button would redirect to a default confirmation page, you may want to code a custom delete action which may override this.
In the footer there should be a link for adding a new meter reading and when the user clicks on it, a new blank row should be
added dynamically to the table and the user should be able to make a
new entry into it.
I suggest creating a small ajax form. Create a "Add Meter Reading" button in it, which on submission would create a meter reading node in the server. The ajax form should have parent information in a hidden field ( i.e. the Meter id). The ajax response for this form could be another script to load/refresh the view on client side.
Client side code to refresh the view can be found in Views Autorefresh submodule in Views Hacks.
If using views megarow you would have to add another jquery function on ajax response after view is refreshed - Trigger edit button.
Otherwise you may have to add some classes or theme to newly created rows in view to bring them to focus.
It is important that the entire views refreshes, so that drupal behaviours are attached to the newly created entry in table.
I don't know if there is one module which will meet all your needs but you may be able to use some in combination.
Views Bulk Operations (VBO) - has Drupal 7 support
This module augments Views by allowing bulk operations to be executed
on the displayed rows. It does so by showing a checkbox in front of
each node, and adding a select box containing operations that can be
applied. Drupal Core or Rules actions can be used.
editablefields - Drupal 7 version in dev
This module allows CCK fields to be edited on a node's display (e.g.
at node/123), not just on the node edit pages (e.g. node/123/edit). It
also works within views etc. Anywhere a 'formatter' can be selected,
you can select editable (or click to edit).
editview - no Drupal 7 support yet but I thought I would mention it in case you're able to adapt the code yourself
Editview is a plugin for the Views module. It allows you to create a
view in which the nodes are editable, and new nodes can be created.

Resources