XF 2.0 How to extend XF\Pub\View\Attachment\View

AndyB

Well-known member
I would like to extend the XF\Pub\View\Attachment\View.

My PHP code:

PHP:
<?php

namespace Andy\OpenPDF\XF\Pub\View\Attachment;

class View extends XFCP_View
{
    public function renderRaw()
    {

    }
}


Trying to add the class extensions:

1516673951188.webp

This is the error message when I click Save:

1516674089790.webp

What am I doing incorrectly?
 
What am I doing incorrectly?
That error is only returned when the autoloader can't find the file that should contain that class. Make sure your class and file location correspond to one another and are in the proper place.
 
That error is only returned when the autoloader can't find the file that should contain that class. Make sure your class and file location correspond to one another and are in the proper place.

Hi Jeremy,

I checked and all seems to be correct:

1516678552994.webp
 
The naming is a bit off, really.

It should really be:
Code:
namespace Andy\OpenPDF\XF\Pub\View;

class Attachment extends XFCP_Attachment {}

No need for a view class to have the name view, it's just bad naming.
 
XF\Pub\View\Attachment\View is the original class name on account of it being a view which renders when viewing an attachment.
 
Yes, but there is a deleted post by Andy after that which suggests the code was still not being called. I assume the deletion means that he noticed that issue and resolved it.
 
I assume the deletion means that he noticed that issue and resolved it.

Hi Chris,

I have yet to resolve this. I have tried for hours and cannot get it to work.

Is this correct?

PHP:
<?php

namespace Andy\OpenPDF\XF\Pub\View\Attachment;

class View extends XFCP_View
{
    public function renderRaw()
    {
        echo 'hello world';
    }
}

Is this correct?

1516732423570.webp
 
The same issue applies as what @Jaxel mentioned right at the start. XF\Pub\View\Attachment is the namespace of the file you're extending. The full class name is XF\Pub\View\Attachment\View.
 
Now it's working perfect.

Thank you Chris, Jeremy, Jaxel and Robust.

PHP:
<?php

namespace Andy\OpenPDF\XF\Pub\View\Attachment;

class View extends XFCP_View
{
	public function renderRaw()
	{
		echo 'hello world';
		exit();
	}
}

1516734374221.webp
 
Last edited:
Back
Top Bottom