This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

octobro
octobro

I have a plugin which rotates banners on the home. I have a link field in the database but instead of copy/pasting the url everytime, is there a way of calling a list of all static pages and clicking to link?

DMeganoski
DMeganoski

Well, normally what you would want to do is define the relation between models... except that the static pages aren't stored in the database at all. You can retrieve a list of related objects, though. Here is how.


           $theme = Cms\Classes\Theme::getEditTheme();
        $page_records = Cms\Classes\Page::listInTheme($theme, true);
        foreach ($page_records as $name => $page_object) {
            $pages[$name] = $page_object->attributes['url'];
        }

Now all you have to do is figure out how to create a custom dropdown and use this data for the list.

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.