Components or Widgets

32 views
Skip to first unread message

Konstantin Gorbachov

unread,
Apr 24, 2014, 4:10:08 AM4/24/14
to sai...@googlegroups.com
Hello, i have couple of questions: 

1. How could i get full or relative current url (/projects and so on) in layout file or service? I found sails.getBaseurl() method, but it returns only host and port: http://127.0.0.1:1337/

2. Is there any way to create component or widget.

For example i want to have Menu widget, with next configuration:

var menuItems = [
   {title: 'Item1', url: '/link1'},
   {title: 'Item2', url: '/link2', active: function() { return someCondition(); }  },
]

and this widget will return <ul><li>.....</li></ul> html content.

I think it could be done via service named by Widget and then in view i will use:   <%- Widget.render('menu')  %>. But how could i render any view from service method?
Widgets view could be located /views/widgets: /views/widgets/menu.ejs

I think it will be very userfull feature.

germ...@gmail.com

unread,
Dec 26, 2016, 9:38:51 AM12/26/16
to sails.js
Hi Konstantin, did you find a solution for this? I believe you've worked with Yii2, if not, Yii2 has widgets which do exactly what you are asking. I was wondering if there was something similar or how to implement this on Sails.
Reply all
Reply to author
Forward
0 new messages