Announcement

Collapse
No announcement yet.

Need help generating custom HTML view URL similar to "#About"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help generating custom HTML view URL similar to "#About"

    Hi everyone,

    I'm looking to generate a URL that loads a view similar to the "#About" page where I can incorporate my own HTML content. Can anyone provide guidance on how to achieve this? I've attempted to replicate the About.js file but haven't been successful so far. I would greatly appreciate any advice or suggestions on this matter.

    Thank you in advance for your assistance!

  • #2
    1. Create custom/Espo/Custom/Resources/metadata/clientDefs/MyPage.json

    Code:
    {
        "controller": "custom:controllers/my-page"
    }

    2. Create custom/Espo/Custom/Resources/metadata/app/clientRoutes.json

    Code:
    {
        "MyPage": {
            "params": {
                "controller": "MyPage"
            }
        }
    }
    ​

    3. Create client/custom/src/controllers/my-page.js

    Code:
    define(['controller'], Controller => {
    
        return class extends Controller {
    
            actionIndex() {
                this.main('custom:views/my-page');
            }
        }
    });
    ​

    4. Create client/custom/src/views/my-page.js

    Code:
    define(['view'], View => {
    
        return class extends View {
    
            templateContent = `
                <div>Test</div>
            `
    
            setup() {}
            
            afterRender() {}
        }
    });
    ​

    Clear cache.

    Comment


    • #3
      I have followed it step by step, but when I clear the cache and rebuild, I get a 404 error. Do you mean this URL?


      Is there something else I might be missing?​

      Click image for larger version

Name:	image.png
Views:	131
Size:	12.2 KB
ID:	102904

      Click image for larger version

Name:	image.png
Views:	121
Size:	23.2 KB
ID:	102905
      Last edited by dabasystem; 02-19-2024, 03:57 PM.

      Comment


      • #4
        Something wrong in views/my-page.js. Maybe misspelled "templateContent". If you attach it here, it'll be able to say.

        Comment


        • #5
          It may be because we are using version 7.0.10. Is it possible to perform it in this version?

          Comment


          • #6
            > Is it possible to perform it in this version?

            Yes. It's the reason. You can define the template in a separate file. It will work in v7.0. See our docs.
            Last edited by yuri; 02-20-2024, 08:45 PM.

            Comment

            Working...
            X