Welcome Guest, Not a member yet? Register   Sign In
How to get the file name of the view being displayed?
#1

[eluser]callumd[/eluser]
Is there a quick and easy way to identify which view file I am looking at when a page renders? (Other than following the logic through the controller class, function name, etc).

Thanks.
#2

[eluser]WanWizard[/eluser]
echo __FILE__ in the view?
#3

[eluser]callumd[/eluser]
I don't know the file name of the view..
#4

[eluser]smilie[/eluser]
__FILE__ is PHP constant which stores current file...

So, literaly, put:

echo __FILE__ and you will see filename Smile

Cheers,
Smilie
#5

[eluser]callumd[/eluser]
Where do I put it? I can't put it in the view..
#6

[eluser]smilie[/eluser]
Well, yes you can...

<?=__FILE__;?>

But, what do you want to achieve?

Cheers,
Smilie
#7

[eluser]callumd[/eluser]
No I mean, I am looking at a webpage in my web browser and I can easily see the view has errors.

So, I need to go and find that view file so I can fix the code.

But the URL does not tell me which view is being loaded. It tells me which controller and class is being loaded.

Is there a way I can quickly find out which view has been loaded without following the logic through my controller?

Thanks.
#8

[eluser]John_Betong[/eluser]
Maybe try this:

View webpage source

Find the error

Select some relevant text near where you know will be in the view (eg: class='this-or-that' id='whatever')

Use your editor to search all your view files for the selected text
 
 
 
#9

[eluser]callumd[/eluser]
That's a good idea John_Betong, thanks. Still not quite elegant enough though.

I'm new to frameworks.. is needing to quickly identify which view you are looking at not a problem other people have already solved?
#10

[eluser]John_Betong[/eluser]
maybe try this:

http://ellislab.com/forums/viewthread/173910/#826452




Theme © iAndrew 2016 - Forum software by © MyBB