# V8: page controller action is empty

**URL:** https://forums.concretecms.org/t/v8-page-controller-action-is-empty/368
**Category:** Developing with Concrete
**Created:** [July 18, 2021, 2:47am UTC](https://forums.concretecms.org/t/v8-page-controller-action-is-empty/368 "2021-07-18T02:47:54Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![linuxoid](https://forums.concretecms.org/user_avatar/forums.concretecms.org/linuxoid/32/5311_2.png) [@linuxoid](https://forums.concretecms.org/u/linuxoid)
#### Post date: [July 18, 2021, 2:47am UTC](https://forums.concretecms.org/t/v8-page-controller-action-is-empty/368/1 "2021-07-18T02:47:55Z")

</div>

I get a page object from a page view event and then try to get its action and parameters but the action returns empty. The page is ‘items’, action is ‘item’, parameter is ‘123’, i.e. /items/item/123. What’s wrong here?

```php
    Events::addListener('on_page_view', function($event) {
        $page = $event->getPageObject();
        $page_controller = $page->getPageController();
        $page_action = $page_controller->getAction();
        \Log::Info('action: '.$page_action); // <- this returns nothing
    }

```

The `getControllerActionPath()` returns ‘items’ though, so that’s the right page.

---

<div class="post-metadata">

### Author: ![linuxoid](https://forums.concretecms.org/user_avatar/forums.concretecms.org/linuxoid/32/5311_2.png) [@linuxoid](https://forums.concretecms.org/u/linuxoid)
#### Post date: [July 21, 2021, 3:59am UTC](https://forums.concretecms.org/t/v8-page-controller-action-is-empty/368/3 "2021-07-21T03:59:56Z")

</div>

Does anyone know how to get the action name from a visited page?

---

<div class="post-metadata">

### Author: ![linuxoid](https://forums.concretecms.org/user_avatar/forums.concretecms.org/linuxoid/32/5311_2.png) [@linuxoid](https://forums.concretecms.org/u/linuxoid)
#### Post date: [July 29, 2021, 9:49pm UTC](https://forums.concretecms.org/t/v8-page-controller-action-is-empty/368/4 "2021-07-29T21:49:47Z")

</div>

Anyone? Any clue? Anyone know?

I also tried `$page_controller->getRequestAction()` and it’s also empty

I’ve also tried with a block controller, i.e. I find the block on the page, get its controller then get its action - it’s also empty.

Ridiculous! How do I get an action from the URL then?

---

<div class="post-metadata">

### Author: ![Myq](https://forums.concretecms.org/user_avatar/forums.concretecms.org/myq/32/4281_2.png) [@Myq](https://forums.concretecms.org/u/Myq)
#### Post date: [July 30, 2021, 7:08pm UTC](https://forums.concretecms.org/t/v8-page-controller-action-is-empty/368/5 "2021-07-30T19:08:42Z")

</div>

Is this for a single page? If so, there’s a pretty good example of how to do it here: [Sending Data To and From a Controller into the Page View](https://documentation.concretecms.org/developers/pages-themes/working-with-pages/single-pages/sending-data-to-a-page-view)

If it’s for a block, you can try: [Example: Passing Data from a custom URL into a Block's View Layer](https://documentation.concretecms.org/developers/working-with-blocks/creating-a-new-block-type/interactive-blocks/passing-data)

If you have another use case, you may need to provide more details.

---

<div class="post-metadata">

### Author: ![linuxoid](https://forums.concretecms.org/user_avatar/forums.concretecms.org/linuxoid/32/5311_2.png) [@linuxoid](https://forums.concretecms.org/u/linuxoid)
#### Post date: [July 30, 2021, 11:22pm UTC](https://forums.concretecms.org/t/v8-page-controller-action-is-empty/368/6 "2021-07-30T23:22:11Z")

</div>

@Myq please have a loo at the very first post - I need to get the viewed page URL action and parameters in the event listener. I’ve tried both a PageController and a BlockController to get the action and they both return empty.

---

<div class="post-metadata">

### Author: ![linuxoid](https://forums.concretecms.org/user_avatar/forums.concretecms.org/linuxoid/32/5311_2.png) [@linuxoid](https://forums.concretecms.org/u/linuxoid)
#### Post date: [August 6, 2021, 3:42am UTC](https://forums.concretecms.org/t/v8-page-controller-action-is-empty/368/7 "2021-08-06T03:42:12Z")

</div>

Looks like changing the event to `on_before_render` and getting `$page = Page::getCurrentPage();` got me the page action and parameters, although not what I expected.

The page is ‘items’, action is ‘item’, parameter is ‘123’, i.e. /items/item/123. I have this in the controller:

```php
    public function action_item($handle = null) 
    {
        $this->runAction('item');
        
        if ($handle) {
            $this->view($handle);
        }
    }

```

What I get from the event is:

```
action: view
parameters: array(2) {
[0]=>
string(4) "item"
[1]=>
string(3) "123"
}

```

Although I can live with that, but why is the action ‘view’, not ‘item’, while the ‘item’ is a parameter instead?

---

<div class="post-metadata">

### Author: ![Myq](https://forums.concretecms.org/user_avatar/forums.concretecms.org/myq/32/4281_2.png) [@Myq](https://forums.concretecms.org/u/Myq)
#### Post date: [September 9, 2021, 12:16am UTC](https://forums.concretecms.org/t/v8-page-controller-action-is-empty/368/8 "2021-09-09T00:16:29Z")

</div>

@linuxoid, you could use `getRequestAction()`:

```php
Events::addListener('on_before_render', function($event) {
    $page = Page::getCurrentPage();
    $page_controller = $page->getPageController();
    $page_action = $page_controller->getRequestAction();
    \Log::Info('action: '.$page_action); // <- returns `item'
});

```

![Screenshot from 2021-09-08 17-15-06](https://forums.concretecms.org/uploads/default/original/1X/523c42ace12c0c3835785a9a0bd6aa73fb8da6c6.png)
