Forum Discussion

Willem's avatar
Willem
Guide
9 years ago

href path difference between component and endpoint

Hi,

 

Im trying to (re)load the idea's dynamicly with AJAX.

 

 

<#assign max_image_width = settings.name.get("layout.message_body_image_max_size", "1000") />
<#assign image_resize_css = "lia-message-body-content" />
<#assign statusUpdates = rest("2.0","/search?q=" + "SELECT * FROM messages WHERE conversation.style='idea' and depth=0 limit 15"?url)/>

<#if statusUpdates.data?has_content>
  <#list statusUpdates.data.items as message>
    <#assign rest_call = "rest_2.0:/messages/${message.id}" />
    <div class="idea-tile idea-${message.id}" >
      <@component id="ideas.widget.idea-message-view" message=rest_call maxWidth=max_image_width resizeCss=image_resize_css />
    </div>
  </#list>
</#if>

 

 

This show the idea widgets with the ability to give kudo to it.

When i run this from my component, it works great.

When i put it in an endpoint to enable some AJAX functionality all href links go to a 404.. corrupted links

- go to detailpage of idea = corrupted

- give/revoke kudo = corrupted

- etc etc.. all 'forwarded' links = corrupted/bad/wrong

 

For example the kudos result :

 

Examplecode in the Component:
href=https://community.lithium.com/t5/ideas/v2/ideaexchangepage.kudosbuttonv2.kudoentity:kudoentity/kudosable-gid/5481?t:ac=blog-id/idea-suggestions&t:cp=kudos/contributions/tapletcontributionspage

200 - OK


Examplecode in the  Endpoint, which is called by the Component:
href=https://community.lithium.com/[communityname]/components/componentdisplaycontributionpage.kudosbuttonv2.kudoentity:kudoentity/kudosable-gid/5481?t:cp=kudos/contributions/tapletcontributionspage

404 - error

 

Is there a way of giving the right 'base' path to an endpoint?

10 Replies

  • Wendy_S's avatar
    Wendy_S
    Boss
    8 years ago

    Sorry to hear that Willem

    I can see if our Dev has some ideas but obviously I can't guarantee anything since I am a developer Nobody myself.

    Willem, Nederlandse naam? Kennen wij elkaar? ;-)

     

    Greetings
    Wendy

  • Willem's avatar
    Willem
    Guide
    8 years ago


    Hi Wendy,

     

    Yes, a more Dutch name is hardly possibly :-) . I guess we haven't met (until now ;-)), didnt knew Lithium had also some/a dutchy in their support line.

    Thanks for poking around too. If im right, AlexN got triggered aswell. 2 poking people might have a bit more luck then 1. 

     

    You do know that from now on ill bug you too whenever i run into problems.  

  • Wendy_S's avatar
    Wendy_S
    Boss
    8 years ago
    Hi Willem.

    I am not a Lithium employee but a community manager (just like you?) and happen to work with a great developer myself. I just don't know if this is amongst his areas of expertise.

    I hope someone from Lithium comes to the rescue or any other badass developer perhaps.



    Ik duim voor je
    Groetjes

    Wendy


  • Willem's avatar
    Willem
    Guide
    8 years ago

    Ahh that way.. As you spoke about 'poking a devver' i made the assumption of a lithium devver ;-).

     

    Im the developer of our team :-) So most likely you know my 'Community Manager' ( Bedrijf met Oranje leeuw als logo )

    Bedankt voor die duimpjes omhoog, wij willen gewoon weer iets wat te moeilijk is, zoals gewoonlijk :D

    Gr,

    Willem

  • Wendy_S's avatar
    Wendy_S
    Boss
    8 years ago
    Hey, Willem

    I have met your colleagues Marco and Tom at headquarters Oranje Leeuw (Mijn Bank!!)

    I think you are more up north?

    Anyway, poked my dev and hopefully an answer will come from somewhere.

    Cheers
    Wendy
  • fuenteso's avatar
    fuenteso
    Leader
    8 years ago

    Oh, looks like an OOB component, maybe a Lithium engineer would be able to answer that question since I don't think there's any documentation for OOB component. Sorry.

  • ClaudiusH's avatar
    ClaudiusH
    Khoros Alumni (Retired)
    8 years ago

    Goedemorgen Willem,

     

    I recall running into a similar problem. The difference is that for an endpoint the context objects are not populated with the current session. This actually makes sense, as endpoints are built to be called remotely. I suggest you restructure your architecture to have the endpoint only supply the data, but your component - which calls the endpoint - then building the actual idea layout. This will ensure the necessary environment variables are set.

     

    If that's not applicable to your scenario, e.g. because you want to use the endpoint to expose your ideas on a non-community page, then you would can also rebuild the idea widget yourself in the endpoint using plain HTML and re-using the Lithium classes.

     

    Maybe you can share what you are trying to accomplish then some better direction can be given on how to achieve it.

  • Willem's avatar
    Willem
    Guide
    8 years ago

    Hi ClaudiusH,

     

    Thanks for your response. If i wouldnt need to use an endpoint to reach the same goal, that is also fine. I dont know howto in this situation.

    What i try to do (pseudo code):

     

     

    <page>
    	<filters onchange="getNewData(theme)">
    	<filters onchange="getNewData(state)">
    	<ajax data container/>
    	<javascript>
    		function getNewData(theme,state){
    			AJAXcall(url = endpoint){
    				<ajax data container>.setHTML(AjaxData)
    			}
    		}
    		function loadOneMorePage(){
    			AJAXcall(url = endpoint){
    				<ajax data container>.addHTML(AjaxData)
    			}
    		}
    	</javascript>
    </page>
    
    <endpoint>
    	<assign query = [createAPIv2 CALL according to filter settings]"?url)/>
    	<assign dataSet = rest("2.0","/search?q=" +query?url)/>
    	
    	<#list statusUpdates.data.items as message>
    		<#assign rest_call = "rest_2.0:/messages/${message.id}" />
                    <@component id="ideas.widget.idea-message-view" message=rest_call maxWidth=max_image_width resizeCss=image_resize_css />
    	</#list>
    </endpoint>

     

    The page loads an initial set of Ideas.

    The user can adjust the set of filters to get a specific set of ideas. previously this happened by a 'pageload' and only 1 filter could be active at the time. Now we have 2 filter options: Theme and State.

     

    What my goal is:

    My idea was to make the dataset loaded with AJAX, so i can change the filters and only the datacontainer gets uploaded.

    As far my knowlegde goes, with freemarker you need to use then endpoints.

    Also instead of paginator, the set gets extended once the user reaches the bottom.

     

    In short:

    - being able to use multiple filters simultaneous.

    - auto add next set of ideas instead the old pagination

     

    It works now on:

    https://community.ing.nl/t5/Ideeen/idb-p/idea-suggesties

     

    The problem is that i had to 'turn off' the basic idea tile component buttons as all those links got corrupted, i would like to be able to use those aswell, ( for example the like-this-idea-button )

  • Willem's avatar
    Willem
    Guide
    8 years ago
    fuenteso

    True, there is a lack of documentation of OOB Components, making the puzzle a lot harder :D