Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pradeep 39 posts 158 karma points
    Jun 08, 2015 @ 09:40
    Pradeep
    0

    How get members profile property without login and display on public page

    Hello,

    How I am able to get all members profile proerty without login and display on public page for search...

    Example as like ...

    1. I am having a member type called teacher 

    2. Member type having custom textbox as like name , address , subject ... etc.

    What I want to here that ..

    1. Teachers can login and edit profile item.. ( I complete it ) 

    2. How I get all teachers profile information as name , address , subject ...  so that students can view them on search page without login ..

    Please any one help me , how I can do that .... any example ?

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jun 08, 2015 @ 10:33
    Alex Skrypnyk
    0

    Hi Pradeep,

    What version of Umbraco are you using?

    If you are using latest you have to use MemberService for getting all information about members. Docs here :

    https://our.umbraco.org/documentation/Reference/Management-v6/Services/MemberService

    Thanks, Alex

  • Pradeep 39 posts 158 karma points
    Jun 08, 2015 @ 12:23
    Pradeep
    0

    Hi Alex , 

    Thank you very much  for reply , Yes I am using latest version of Umbraco .. 

    How I get all the information and display on page and result based on search .... 

    So , Can you please provide me codes , and  also how I able to filter result based on location too.

    -------------------------------------------------------------------------------------------

    @inherits Umbraco.Web.Macros.PartialViewMacroPage

    @using Umbraco.Core;

    @using Umbraco.Core.Models;

    @using Umbraco.Core.Services;

    @{ 

     var agents = Services.MemberService.GetMembersByMemberType("agents");

    }

     @foreach(var item in agents)

       {

         

    @item.Name

         

    @item.Company

         

    @item.Email

     

      }

    ----------------------------------

    Thanks

    Waiting for reply 

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 08, 2015 @ 13:32
    Dennis Aaen
    1

    Hi Pradeep,

    Custom fields are retrieving by method GetValue(), so for the fields like e.g name , address , subject you can do it like this

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @using Umbraco.Core;
    
    @using Umbraco.Core.Models;
    
    @using Umbraco.Core.Services;
    
    @{ 
    
     var agents = Services.MemberService.GetMembersByMemberType("agents");
    
    }
    
     @foreach(var item in agents) {
    
       @item.Name
    
       @item.Company     
    
       @item.Email
    
       @item.GetValue("address")
    
     }
    

    Hope this helps,

    /Dennis

  • Pradeep 39 posts 158 karma points
    Jun 08, 2015 @ 14:51
    Pradeep
    0

    Hi  Dennis, Thanks for reply , its nice we can use getvale method ...

    But the macro is not working , error in loading , I  not get any idea , what is problem there...

    Please current my syntax for macro

    -Thanks

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jun 08, 2015 @ 15:29
    Alex Skrypnyk
    0

    Pradeep, can you look at traceLog ?

  • Pradeep 39 posts 158 karma points
    Jun 08, 2015 @ 15:47
    Pradeep
    100
    error CS0103: The name 'Services' does not exist in the current context at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) at System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath) at System.Web.Mvc.BuildManagerViewEngine.FileExists(ControllerContext controllerContext, String virtualPath) at Microsoft.Web.Mvc.FixedRazorViewEngine.Microsoft.Web.Mvc.IViewEngineProxy.FileExists(ControllerContext controllerContext, String virtualPath) at Microsoft.Web.Mvc.ViewEngineFixWorker`1.GetPathFromSpecificName(ControllerContext controllerContext, String name, String cacheKey, String[]& searchedLocations) at Microsoft.Web.Mvc.ViewEngineFixWorker`1.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations) at Microsoft.Web.Mvc.ViewEngineFixWorker`1.FindPartialView(ControllerContext controllerContext, String partialViewName, Boolean useCache) at Microsoft.Web.Mvc.FixedRazorViewEngine.FindPartialView(ControllerContext controllerContext, String partialViewName, Boolean useCache) at Umbraco.Core.Profiling.ProfilingViewEngine.FindPartialView(ControllerContext controllerContext, String partialViewName, Boolean useCache) at System.Web.Mvc.ViewEngineCollection.<>c__DisplayClass8.b__7(IViewEngine e) at System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths) at System.Web.Mvc.ViewEngineCollection.FindPartialView(ControllerContext controllerContext, String partialViewName) at Umbraco.Web.Mvc.ControllerExtensions.EnsureViewObjectDataOnResult(ControllerBase controller, ViewResultBase result) at Umbraco.Web.Mvc.ControllerExtensions.RenderViewResultAsString(ControllerBase controller, ViewResultBase viewResult) at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, IPublishedContent content) at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, INode node) at umbraco.macro.LoadPartialViewMacro(MacroModel macro) at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
       
  • Pradeep 39 posts 158 karma points
    Jun 08, 2015 @ 15:50
    Pradeep
    0

    sorry by mistake  i click on solution

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jun 08, 2015 @ 15:50
    Alex Skrypnyk
    1

    Try to change to :

    var agents = ApplicationContext.Current.Services.MemberService.GetMembersByMemberType("agents");
    
  • Pradeep 39 posts 158 karma points
    Jun 08, 2015 @ 15:59
    Pradeep
    0

    Hi Alex ,

    Thanks its started working now ...

    So , I am having a state list and I want to show all agent by state page ..

    What I Have ...

    1. I created a document type state and agents and member type as agents ...

    2. How I able to get all member information as on every state page ... ( example like if any agents belongs to CA then all member list show on CA page )

    How I can do that ,,,,

    Thanks again for your help...

     

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jun 08, 2015 @ 16:18
    Alex Skrypnyk
    0

    You have to filter members somehow. How do you recognize where agent is belong ?

  • Pradeep 39 posts 158 karma points
    Jun 08, 2015 @ 16:21
    Pradeep
    0

    By adding a Custom fields ....

    .GetMembersByPropertyValue("city", "Horsens"); 

    Its works ??

     

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jun 08, 2015 @ 16:32
    Alex Skrypnyk
    0

    Yes, you can use Linq:

    var agentsFiltered = agents.Where(agent => agent.GetMembersByPropertyValue

  • Pradeep 39 posts 158 karma points
    Jun 08, 2015 @ 16:40
    Pradeep
    0

    Thanks ,,

    Its can be possible any way .... that I will be pass the current page name here ..

    Example like someone visit on CA state page .. ( url like myhome/ca/)

    -----------------------------------------------------

    var statename = @currentpage.Name

    var agentsFiltered = agents.Where(agent => agent.GetMembersByPropertyValue("city").Equals(statename));

    ---------------------------

    How It will be used when search ....  same ?

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jun 08, 2015 @ 17:00
    Alex Skrypnyk
    0

    This code will return agents from current city, what isn't right ?

  • Pradeep 39 posts 158 karma points
    Jun 08, 2015 @ 17:07
    Pradeep
    0

    Yes ,code is working fine ...

     var states = ApplicationContext.Current.Services.MemberService.GetMembersByPropertyValue("state","CA");

     
  • Pradeep 39 posts 158 karma points
    Jun 08, 2015 @ 17:19
    Pradeep
    0

    Thanks alex ...

    I hope everything works fine ...  , if I have any issue let you know .

     

    Thanks again for your help

Please Sign in or register to post replies

Write your reply to:

Draft