How do I access certain entity associated files from another portal in 2sxc module? - dotnetnuke

I want to access multiple files from single field of certain entity, which is at different portal. The problem is that when I try to use this example or this one, its field of type Hyperlink contains empty string and method AsAdam(entityObj, "FieldWithFiles").Files as IEnumerable<dynamic> returns empty IEnumerable<dynamic>.
So is there a way to get files data from another portal in module 2sxc?
Environment used:
DNN v.9.6.1
2sxc v.11.5.0

This may fix itself in v11.11, but the general method is as follows:
Get the real file id (instead of the url) by accessing the raw APIs first - kind of like this
var entity = AsEntity(Content);
var realLink = entity.GetBestValue<string>("FieldNameWhichHasTheLink");
// now you have something like file:74 in realLink
// now continue with the DNN API to figure out what file 74 is, and if the permissions allow access

Related

Get page URL for scheduled publishing

My editors want to know the end page url for publishing in social media.
Is there any way to get the page URL as when it will be published before actually publishing it (scheduled publishing)?
slug_url should give you what you need:
https://docs.wagtail.org/en/latest/topics/writing_templates.html?highlight=slugurl#slugurl-tag
Note that slugurl might provide a relative link, so if it does, then you would have to prepend the domain name to the relative url in order to create the final url for the user. See the test_slugurl_tag() routine in the tests for an example of how to use slugurl in Python code.
Note also that if the location of the page in the page tree is changed or the slug (as defined in the Promote tab) is changed, then the url that you retrieved with slugurl prior to any such change will no longer be valid. However, if you are using Wagtail 2.16+, then this problem can be handled automatically if you use the wagtail.contrib.redirects app.
Here a code snippet that takes in account when the slug changes or the page is moved in the tree (you will need to subclass the Page model somehow and add a new field published_url):
def save_revision(self, user=None, submitted_for_moderation=False, approved_go_live_at=None, changed=True,
log_action=False, previous_revision=None, clean=True):
old_record = Page.objects.get(id=self.id)
if old_record.slug != self.slug:
kwargs = {'update_fields': ['slug']}
Page.save(self, kwargs)
self.published_url = self.get_full_url()
return Page.save_revision(self, user, submitted_for_moderation, approved_go_live_at, changed,
log_action, previous_revision, clean)

How to bind uploaded file with ADAM to entity field correctly in 2sxc module?

I need to create entity object programmatically and fill it with data. One field needs to be of a file type. So I managed to create entity without file, upload file in ADAM using this sample of code. However it seems that I didn't bind it as it is binded when file is uploaded manually.
When a file is uploaded to entity field manually, you can see content like file:421 .../asdf.docx. However when I repeat code sample from link above, field contains that file available to choose and already uploaded, but field value is null. IFile.Url seems to write correct data via App.Data.Update method, but no id is displayed in admin panel.
Dictionary<string, object> fileDict = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase) {
{ "File", file.Url }
}; // file is ToSic.Sxc.Adam.IFile, returned by SaveInAdam
App.Data.Update(entityObj.EntityId, fileDict); // entityObj is ToSic.Eav.Data.IEntity, returned by App.Data.Create
I wonder if that's going to have some bad conscequences if it has no binding like manual upload and how to do that correctly?
To add files, you actually add them to a field (so that the UI can then offer them as if they were added by a normal user). Check out https://docs.2sxc.org/api/dot-net/ToSic.Sxc.Dnn.Web.IDynamicWebApi.html#ToSic_Sxc_Dnn_Web_IDynamicWebApi_SaveInAdam_System_String_System_IO_Stream_System_String_System_String_System_Nullable_System_Guid__System_String_System_String_
BTW: Best check out MobiusForms to see how it's done.
And I forgot to mention: here the docs https://docs.2sxc.org/web-api/custom-web-api-dotnet-saveinadam.html
To further explain:
SaveInAdam will place the file in the ADAM folder of the item. Since it could be that many files are added, it's just assuming that the field will be the library type - which doesn't store anything in the entity, it just automatically finds the folder that belongs to the field.
If you wish to not use the library feature but actually just the single-field with link, then you must also save the term like "file:74" into the value of the field.

SuiteCommerce Advanced - Show a custom record on the PDP

I am looking to create a feature whereby a User can download any available documents related to the item from a tab on the PDP.
So far I have created a custom record called Documentation (customrecord_documentation) containing the following fields:
Related item : custrecord_documentation_related_item
Type : custrecord_documentation_type
Document : custrecord_documentation_document
Description : custrecord_documentation_description
Related Item ID : custrecord_documentation_related_item_id
The functionality works fine on the backend of NetSuite where I can assign documents to an Inventory item. The stumbling block is trying to fetch the data to the front end of the SCA webstore.
Any help on the above would be much appreciated.
I've come at this a number of ways.
One way is to create a Suitelet that returns JSON of the document names and urls. The urls can be the real Netsuite urls or they can be the urls of your suitelet where you set up the suitelet to return the doc when accessed with action=doc&id=_docid_ query params.
Add a target <div id="relatedDocs"></div> to the item_details.tpl
In your ItemDetailsView's init_Plugins add
$.getJSON('app/site/hosting/scriptlet.nl...?action=availabledoc').
then(function(data){
var asHtml = format(data); //however you like
$("#relatedDocs").html(asHtml);
});
You can also go the whole module route. If you created a third party module DocsView then you would add DocsView as a child view to ItemDetailsView.
That's a little more involved so try the option above first to see if it fits your needs. The nice thing is you can just about ignore Backbone with this approach. You can make this a little more portable by using a service.ss instead of the suitelet. You can create your own ssp app for the function so you don't have to deal with SCAs url structure.
It's been a while, but you should be able to access the JSON data from within the related Backbone View class. From there, within the return context, output the value you're wanting to the PDP. Hopefully you're extending the original class and not overwriting / altering the core code :P.
The model associated with the PDP should hold all the JSON data you're looking for. Model.get('...') sort of syntax.
I'd recommend against Suitelets for this, as that's extra execution time, and is a bit slower.
I'm sure you know, but you need to set the documents to be available as public as well.
Hope this helps, thanks.

Is there a clean way of users managing their own locations?

A lot of my site is dynamically generated dependant on the user location.
To get an initial fix I am currently using the Smart_IP module which does this based on the user IP address - which works great as a starting point. I can access $_SESSION['smart_ip']['location']['longitude'] & $_SESSION['smart_ip']['location']['latitude'] as required - perfect!
But I need to allow my user to override this..
Using HTML5 geolocation. I want to only do this on user request, ie click 'locate me', rather than requesting their location uninvited.
Using one of a few pre-defined locations selectable by the user.
Using an inputed address by the user.
Is there any drupal module I can use for this, or how else could I achieve it?
-
Just to clarify, I am talking about anonymous users here - the general public visiting my site. I just want them to be able to refine their 'location' by overriding the defaults I give them using smart_ip.
I suggest to use Geolocation field and all it's submodules or Geofield. Last one provides more input methods.
Use the Address field module to allow the user create multiple addresses into a node (or even into his profile), Geocoder module to get the lon/lat from these addresses and then a Views to display them in a list.
Same as 2 but without views.
If you want to allow user select one of the 3 methods you can use an other - helper - field (eg a select list with the 3 options).
Finally you should add an extra field to store the lat/lon pair final values maybe with Computed field module or 2 simple textfields that will get the selected values through javascript.

Difference between DataControl.cpx and Datacontrol.dcx in Oracle ADF

In Oracle ADF what is the difference between DataControl.dcx and DataControl.cpx ? What goes where ?
Check out the doc at A.7 DataBindings.cpx
Databindings.cpx- Data Binding Registry
Jdeveloper Creates this first time when you data bind a UI Component
It has
pageMap maps all user interface URLs and the corresponding page definition usage name. This map is used at runtime to map a URL to its page definition.
pageDefinitionUsages maps a page definition usage (BindingContainer instance) name to the corresponding page definition. The id attribute represents the usage ID. The path attribute represents the full path to the pagedefinition.
dataControlUsages declares a list of data control usages (shortnames)corresponding path to the data control definition entries is available in datacontrols.dcx file
Datacontrols.dcx -Data Controls Registry
Lists ADF Data control available in a project
It Contains Information needed to initialize the data control to work with. a particular service (Java bean web service ,EJB) J developer Creates this file when you create a data control . This file is not generated for Oracle ADF Business Components

Resources