In the JS file, I want to retrieve the URL and get the guid of the member.
It works when I view the first member, but when I go the next member I see the previous members' details, until i refresh the page.
Somehow this part gets cached or something like that:
var parts = window.location.href.split('/');
var lastSegment = parts.pop() || parts.pop(); /// user guid:/umbraco#/member/member/edit/aeacde7b-ed76-4d71-94bc-83be7b21695d -> aeacde7b-ed76-4d71-94bc-83be7b21695d
angular.module("umbraco").controller("MemberDownloads", function ($scope, taggedResource) {
$scope.newTag = '';
$scope.alltags = [];
taggedResource.getTags().then(function (res) {
var data = res.data;
for (var tag in data) {
var name = tag;
if (data.hasOwnProperty(tag)) {
$scope.alltags.push([tag, data[tag]]);
}
}
});
});
angular.module("umbraco.resources").factory("taggedResource", function ($http) {
var taggedService = {};
var parts = window.location.href.split('/');
var lastSegment = parts.pop() || parts.pop(); // user guid:/umbraco#/member/member/edit/aeacde7b-ed76-4d71-94bc-83be7b21695d -> aeacde7b-ed76-4d71-94bc-83be7b21695d
taggedService.getTags = function () {
return $http.get("/umbraco/surface/MemberDownloads/GetDownloads/" + lastSegment, { timeout: 2000 });
};
return taggedService;
});
angular.module("umbraco").controller("MemberDownloads", function ($scope, taggedResource) {
$scope.newTag = '';
$scope.alltags = [];
var parts = window.location.href.split('/');
var memberId = parts[parts.length - 1];
taggedResource.getTags(memberId).then(function (res) {
var data = res.data;
for (var tag in data) {
var name = tag;
if (data.hasOwnProperty(tag)) {
$scope.alltags.push([tag, data[tag]]);
}
}
});
});
angular.module("umbraco.resources").factory("taggedResource", function ($http) {
var taggedService = {};
taggedService.getTags = function (memberId) {
return $http.get("/umbraco/surface/MemberDownloads/GetDownloads/" + memberId, { timeout: 2000 });
};
return taggedService;
});
Member Data Type Get sql data
Hi,
I want to create a data type, that will used in the members section. On each member i want to list data from a sql table thats match the member id.
How do i go about this task?
Hi,
Your question is marked as being for umbraco 7, but just a quick note, that In umbraco 8 you would probably do a content app for this :)
In v7, it could be done by implementing a property editor. There are multiple ways to do this. A good starting point would be the documentation https://our.umbraco.com/Documentation/Tutorials/Creating-a-Property-Editor/index-v7
You can find more info/tutorials here: https://24days.in/umbraco-cms/2016/custom-property-editor-tutorial/ https://www.youtube.com/watch?v=FICgnOiwhpY https://www.markadrake.com/custom-umbraco-property-editor-tutorial-character-counts/
Both content and members share datastructure, so the process is the same for both.
Thanks,
I am almost there:
In the JS file, I want to retrieve the URL and get the guid of the member. It works when I view the first member, but when I go the next member I see the previous members' details, until i refresh the page.
Somehow this part gets cached or something like that:
var parts = window.location.href.split('/'); var lastSegment = parts.pop() || parts.pop(); /// user guid:/umbraco#/member/member/edit/aeacde7b-ed76-4d71-94bc-83be7b21695d -> aeacde7b-ed76-4d71-94bc-83be7b21695d
Hi,
In your resource, you only ask for the id once, and then reuse it.
In angular you get the "taggedResource" injencted, so you need to make it stateless.
your "getTags"-method should take the member id as a parameter.
In your controller do:
and in your resource:
hth :)
Thanks,
I just tried that, with no luck.
I have this:
jhmm, it works, must have been a cache problem.
it always is ;)
is working on a reply...