Please help. This should be simple.

Permalink
Help, this is driving me crazy. I want an image from my theme folder to show in a block on my page. I do the following:
Add Block>HTML> and add the following:
<img src="<?php echo $this->getThemePath(); ?>/images/c1.jpg"/>
The images folder lives in root>themes>theme_name>images

I have tried just about every possible way of doing this and it won't work. Can anyone please point out my error? I'm using v5.6.0.1.

 
mesuva replied on at Permalink Reply
mesuva
The HTML block only will display HTML, it won't process PHP.
So the echo $this->getThemePath() simply won't get processed - you would only use something like that when you edit/create a theme file, not in the contents of a block.
WHW1dotCOM replied on at Permalink Reply
Have you tried simply dropping in a Content Block and adding an image in that block and specify the html link?
Gingebean replied on at Permalink Reply
Gingebean
Hi,
The short answer is html block is for html not php
is strips all php out for security reasons ………which kinda makes sense

However if you really want to do it there is addon here
http://www.concrete5.org/marketplace/addons/simple-php-block/...
but you might need to add this also, to get the theme path address
<?php 
$v = View::getInstance();
$v->getThemePath();
?>


but I would strongly recommend anther approach …..like adding image block or building a custom block or even using the content block
anyways it up to you
hope this helped a bit
DanK replied on at Permalink Reply
Okay, thanks I now understand why the php was not working so I think I'm close to the answer.

I'm using a jQuery slider called SlideDeck. I add it to each page I want it to run on with Add Block > HTML and then add the code as below. You'll see that there is no php in the code. The ONLY thing I need to know is how to get the images onto the slideshow in a way that doesn't use an absolute path. The images in localhost work fine but when I upload to the server they'll break. If I could have them in theme/images/c2.jpg that would be brilliant but it won't work. Any help more extremely gratefuly received...

Slideshow code from HTML block:
<div id="slidedeck_frame" class="skin-slidedeck">
         <dl class="slidedeck">
            <dt>NAME OF SLIDESHOW</dt>
            <dd>
                    <ul class="slidesVertical">
                        <li><img src="http://localhost:8888/sitename/files/6113/4868/8002/c2.jpg"/></li>
                       <li><img src="http://localhost:8888/sitename/files/7613/4868/3028/c4.jpg"/></li>
                    </ul>
            </dd>
         </dl>
      </div>
      <script type="text/javascript">
            /* Initiate the SlideDeck */
          $('.skin-slidedeck dl.slidedeck').slidedeck({
                autoPlay: true,
Gingebean replied on at Permalink Reply
Gingebean
If you know the the absolute path to themes image folder then use it.
html block is mostly for static elements (it is a quick fix ..i rarely use it)

if you want dynamic options you are best creating a custom block
There is a free add on that helps you do this
http://www.concrete5.org/marketplace/addons/designer-content/...

or hard code in page or create a "page type" and then you can use you The getThemesPath()
DanK replied on at Permalink Reply
Thanks but if I use the absolute path as I have here, when I upload the site to the server I will have broken links. Do you know what path I can use when developing locally that will still work when I upload to the online server?
Gingebean replied on at Permalink Reply
Gingebean
yeah lol I meant the path on the distant server ...anyways
bearing in mind your page is is being called from root folder
you need somthing like this it depends where your theme is

for package
/packages/mypackage/themes/mytheme/images/myimage.jpg

for theme (in themes folder in root folder)
themes/mytheme/images/myimage.jpg

if its in default contrete theme
concrete/themes/mytheme/images/myimage.jpg

but if you change theme later it will still get images frome this hardcoded address
WHW1dotCOM replied on at Permalink Reply
Would this work for him as it does in the Content Block?
{CCM:BASE_URL}/files/6113/4868/8002/c2.jpg
or
{CCM:BASE_URL}/themes>theme_name>images/c1.jpg
adajad replied on at Permalink Reply
adajad
I didn't think of that...

Try it out!
Gingebean replied on at Permalink Reply
Gingebean
{CCM:BASE_URL}/themes>theme_name>images/c1.jpg
i think u mean {CCM:BASE_URL}/themes/theme_name/images/c1.jpg
this wud give you
www.www.yoursite.com/themes/theme_name/images/c1.jpg...
and this would be same as
/themes/theme_name/images/c1.jpg

so it would work .But again if you change theme code will still get images from old theme path

you would need a global that points directly to theme

I do however agree with adajad thay you might you need to rethink your approach on this

powerlite slider is also a good one which I use
adajad replied on at Permalink Reply
adajad
You could create another page type with SlideDeck and all images with getThemePath() hardcoded in there.

In our other discussion I was assuming you added the slider from within your theme and not by adding it through a block.

Still, I think creating a block out of SlideDeck would be the best option. That way all you would have to do is click an area, add SlideDeck block and specify a fileset (if all instances of the slider will use the same settings you can hardcode them in your block).

Unfortunately I will not be at the office until monday so I will not be able to test it out. If it is an easy setup (SlideDeck) then you might actually manage it without much prior php OR c5 knowledge by following Jordans 'How to build a slideshow block (with Flexislider)': http://c5blog.jordanlev.com/blog/2011/12/build-a-slideshow-block/...

It takes some reading but it might be worth 1-2 hours of work to get over the frustration you must be feeling.
DanK replied on at Permalink Reply
Thanks everybody I'll try out all of your suggestions and hopefully will avoid having a Mac Pro shaped hole in my wall. Adajad, thanks again. I think I now understand what you mean with the Jordan's custom block.

Cheers,
JP
Spletnapot replied on at Permalink Reply
Spletnapot
html or content block(html) ->

<img src="/themes/your-theme/images/c1.jpg" />

thats is.

or upload img and grab it from there.
mhawke replied on at Permalink Reply
mhawke
Thank you Spletnapot for injecting some sanity into this post.

Really? Build a custom block to add an image from your theme directory? I guess it's true that when all you have is a hammer, every problem looks like a nail.
adajad replied on at Permalink Reply
adajad
You obviously don't have the whole story here, so please don't patronize.
Gingebean replied on at Permalink Reply
Gingebean
@mhawke
yeah it actually turns out to be a slider he wants with a dynamic path if you look at code/post above and not just a simple image

What Spletnapot said is right and is basically what I and others have already said if you mhawke had taken the time to read our posts you would seen we have we advised him hardcode this in his template or make a page type for this
but.....
Bearing in mind that he wants a block and the the path names to be dynamic (change theme = change images) then actually sticking aa path name with the theme path hardcoded in there is kinda like throwing a "spanner" in the works of template system(sure no hammer there but ....you get the idea)

for though me a using "custom made block" modifying a an existing slider block is the best option files are stored in file manager and therefore independent of themes

and last mhawke if people take the time to give answers they might not always be right(defiantly me included)... but at least read the reason why think this good idea, and true you do not have to read all the post but if you going judge a commment it best getting all your the info straight first.

....tc and later all I am off to fix my wacom tablet ....now where is my hammer
mhawke replied on at Permalink Reply
mhawke
I am truly sorry if I offended anyone. That was not my intention. I read the entire post before posting my comment but I paid particular attention to what johnpatrick posted rather than the solutions everyone was suggesting. When johnpatrick said, "The ONLY thing I need to know is... ", I read that as a clue that the things being suggested were overkill.

More quotes:

"If I could have them in theme/images/c2.jpg that would be brilliant but it won't work.
"Do you know what path I can use when developing locally that will still work when I upload to the online server?"

My main point is... listen to your patient. It will take a lot longer than 1-2 hours for johnpatrick to build a block if he's never built one before especially if he wants to put 2 instances of the same slider block on the same page and style them differently.
adajad replied on at Permalink Reply
adajad
This whole thread comes as a response to another thread which will give you a bit more background. http://www.concrete5.org/community/forums/customizing_c5/correct-pa...

I know you didn't intend to upset or offend, but in text a lot of things may sound more harsh than they really are.

No offense taken on my part.
Gingebean replied on at Permalink Reply
Gingebean
oh no offense taken here either lol I am just another insane man with a hammer.... really ?
DanK replied on at Permalink Reply
Guys, I have solved the problem. It was so simple that I am totally embarrassed to have caused all this hassle. It was simply a matter of removing thehttp://localhost:8888 part from the address. For some reason this didn't work even when I had a good idea that it should have. That's why I asked the question. Unfortunately my question, as it was so simple probably, was a bit misunderstood and we got into $this->getThemePath and the like. This didn't work and everything snowballed from there.

I can only apologise for starting this nonsense thread and thank you all for generously giving your time to try and help. I really appreciate it.

All the best.
JP.
mhawke replied on at Permalink Reply
mhawke
Good Lord! I didn't see the other thread but who posts 2 identical threads 1 day apart FFS. My apologies all around. I'm out.
DanK replied on at Permalink Reply
The first thread was answers from a single user and had gone in completely the wrong direction. I tried to simplify the problem and start fresh. I wouldn't normally do that but this problem had left me up against an extremely tight deadline. As I said above I really appreciate the help and am not some kind of crazy boy, just someone who really needed some urgent help. Sorry for the inconvenience.
Gingebean replied on at Permalink Reply
Gingebean
johnpatrick...dont worry about we all have moments like that (I have hundreds of them every day )
anyways i am glad you got it sorted !!!!
adajad replied on at Permalink Reply
adajad
Yeah, the first thread and your initial question was totally misunderstood since I thought you wanted help with how you would implement a slider in a theme hard coding the image sources from the file manager.

I'm glad you have found something that suits you.
mhawke replied on at Permalink Reply
mhawke
I guess that was my point with my original 'snarky' comment. I sensed that you were frustrated that the solutions being presented were a hammer when perhaps a glue gun was required. Anyways, glad to see you've got it working and we're all still friends.

And by the way, I agree that the 'Designer Content' block is well worth learning. I use it all the time but it's just not something you'd want to try to learn when your on a tight deadline.