Here's my problem. I want to build a system where I don't need to worry about the paths of files. Right now I have all these "../" to reference different folders on the server.
I want to transform this:
<input type="image" src="../add_post.png" name="post" class="navigation_buttons" id="addPostButton" width="32" height="32">
into this:
<input type="image" src=<?php echo View::image("add_post.png");?> name="post" class="navigation_buttons" id="addPostButton" width="32" height="32">
The image function would just do something like:
public static function image($src) {
return "../images/" . $src;
}
I know this will work because View's directory will never change relative the the folder images:
-> project
-> libs
-> View.php
-> images
-> add_post.png
The heart of my problems is really creating a resource system where I don't need to worry about paths. Just saying View:getImage("image name") would return the source path.
If there's a better way doing this, I'm all ears.
EDIT: My question is also about how to even allow for the html to correctly parse the PHP inline. The most I've gotten is an empty image. The html just doesn't load the image properly. Other times the image doesn't even show up.
Example of my attempt:
public static function get() {
return '<input type="image" src="images/add_post.png" name="post" class="navigation_buttons" id="addPostButton" width="32" height="32">';
}
The HTML:
<div class="buttons">
<a href="pages/PostEntry.php">
<?php echo View::get();?>
</a>
No image button even shows up. I know for a fact that this is the correct image, as the other buttons I have are working properly with their respective HTML.