Copied to clipboard

Flag this post as spam?

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


  • Jojo V 64 posts 166 karma points
    Jul 18, 2019 @ 08:45
    Jojo V
    0

    Get content by URL

    Hi,

    I look for how to get content (ideal from cache) by URL with multiple hostnames in custom API controller UmbracoApiController. I was find method UmbracoContext.Content.GetByRoute but I don't know how to get content for specific hostname / domain.

    For example, how find content for example.com/en/home and anotherdomain.com/en/home. Content this pages is not the same.

    If i set this url to parameter in function UmbracoApiController then I always getnull or error.

    Thanks.

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Jul 20, 2019 @ 23:53
    Marc Goodson
    2

    Hi Jojo

    If you have specific multiple custom hostnames set on your Umbraco site to different root nodes in the content tree - then you can still use GetByRoute..

    but you need to prefix the relative path you are looking for with the id of the Root node for that site domain..

    So GetByRoute("1234/en/home") and GetByRoute("1235/en/home")

    where 1234 is the id of root node for one site, and 1235 is the root node for another...

    I know this is a V7 package PageNotFoundManager by TimGeyssens, but this code gives you a bit of a gist of how the GetByRoute works in a multi site Umbraco implementation.

    https://github.com/TimGeyssens/UmbracoPageNotFoundManager/blob/master/PageNotFoundManager/PageNotFoundContentFinder.cs

    Hope that helps steer in the right direction.

    regards

    marc

  • Damien Holley 180 posts 541 karma points
    Nov 16, 2020 @ 04:21
    Damien Holley
    0

    This doesn't seem to work inside a LastChanceContentFinder

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Nov 16, 2020 @ 19:22
    Marc Goodson
    0

    Hi Damien

    What problem is occurring?

    There is a V8 version of the UmbracoPageNotFoundManager, that has an example of GetByRoute:

    https://github.com/TimGeyssens/UmbracoPageNotFoundManager/blob/dev-v8/PageNotFoundManager/PageNotFoundContentFinder.cs

    That is registered as a LastChanceContentFinder

    https://github.com/TimGeyssens/UmbracoPageNotFoundManager/blob/dev-v8/PageNotFoundManager/PageNotFoundManagerComposer.cs#L18

    that it might be helpful to compare with.

    regards

    Marc

  • Jojo V 64 posts 166 karma points
    Jan 04, 2021 @ 07:24
    Jojo V
    0

    ??

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 04, 2021 @ 09:11
    Lee Kelleher
    1

    @Jojo, the comment you replied to appears to be spam, I've flagged it as such (hence it's removed from this thread). Frustrating, I know.

    Cheers,
    - Lee

  • Heathcote 1 post 71 karma points
    Jan 04, 2021 @ 09:43
    Heathcote
    0

    When I use following URL in browser then it prompt me to download a text file with JSOn content.

    Now I want to create a php page. I want that when I call this php page, it should call above URL and get content(json format) from file and show it on screen.

    How can I do this ??

    MyFordBenefits Login

  • Jojo V 64 posts 166 karma points
    Jan 04, 2021 @ 09:58
    Jojo V
    0

    If you are prompted to download a JSON file, your browser has incorrect settings (default is to display JSON content)

    In PHP, you can simply call "$result = filegetcontents ('UMBAPIURL')". In the variable $result you will have the content of JSON from the UMB API. You can use the PHP function "json_decode()" to decode JSON to an object. Alternatively, use functions / libraries other than cUrl ...

    (I'm also a PHP programmer)

    I just don't understand what this has to do with this post (this is .Net technology).

    PS: You must first have the UMB API programmed

Please Sign in or register to post replies

Write your reply to:

Draft