Looking for advice on some php

15 posts / 0 new
Last post
Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Apr 10 2007 18:51
Looking for advice on some php

Anyone around apart from felix frost who can advise me on some php?

In try to make locations on the left clickable i changed the code from this:

<?php print t('Location:') . '  ' . $location; ?>

To this:

Location: <a href="/profile/profile_location/<?php print $location ?>"> <?php print $location ?></a>

I literally know nothing about php, and just make it up as I go along and hope for the best. In this instance it seemed to work. But I have no idea why? Whats the difference between the first and second? And do is it matter? Could I achieve the same result with the first piece of code? if so how?

Felix Frost's picture
Felix Frost
Offline
Joined: 30-12-05
Apr 10 2007 19:10

I would tell you, but since you asked anyone apart from me...

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Apr 10 2007 19:18

lol you weren't online when you posted and I didn't want to keep asking you questions so i thought i would see if anyone else knew.... but as you are here wink

Felix Frost's picture
Felix Frost
Offline
Joined: 30-12-05
Apr 10 2007 19:26

I'll do the easy questions then, and someone else can answer What's the difference? and Does it matter?

rkn wrote:
Could I achieve the same result with the first piece of code? if so how?

<?php print t('Location:') . ' <a href="/profile/profile_location/' . $location . '"> ' . $location . '</a>';

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Apr 10 2007 19:32

Thanks for that smile From my limited knowledge - what i did was html with some php in it, while what you did was php with some html in it.

Mike Harman
Offline
Joined: 7-02-06
Apr 10 2007 21:46

t('Location:') allows for translation because it's printing as a string (I think) - so if we translated locations then we'd be able to get them to show up, maybe, not that we will so it doesn't matter.

I think php in html looks way nicer.

er...

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Apr 10 2007 22:16

Well with php in html i know how to style 'location' differently from the actual location but how it is now i dont wink

Mike Harman
Offline
Joined: 7-02-06
Apr 10 2007 22:18

should we make profiles available to non-registered users?

Also - we need to kill line break under taglines.

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Apr 10 2007 22:21
Quote:
should we make profiles available to non-registered users

Use but not contact form. If possible.

Quote:
Also - we need to kill line break under taglines.

I put it in on purpose cos it looks shit otherwise as one solid block of text with not enough differentiation. Need to figure out how to set max number of characters tho cos some peoples are way to long.

Also be cool if we could set post boxes to a minimum size to stop formatting fucking up

Mike Harman
Offline
Joined: 7-02-06
Apr 10 2007 22:26

mininum height boxes we can do in ff/opera with min-height. IE6 (not sure about 7 but I think it's the same with this one) doesn't recognise though.

def agree about character limit.

Steven.'s picture
Steven.
Offline
Joined: 27-06-06
Apr 12 2007 10:06
Mike Harman wrote:
def agree about character limit.

word. those cunts putting in locations which aren't real pisses me off too, can we set char limit for that as well?

Mike Harman
Offline
Joined: 7-02-06
Apr 12 2007 10:10

With that it might be better to use location module tbh - then it does a drop down list for countries and stuff, not sure about cities.

Steven.'s picture
Steven.
Offline
Joined: 27-06-06
Apr 12 2007 11:06

ok sounds good.

Felix Frost's picture
Felix Frost
Offline
Joined: 30-12-05
Apr 15 2007 13:46
rkn wrote:
Well with php in html i know how to style 'location' differently from the actual location but how it is now i dont ;)

There isn't really any difference in how you would do that, though. All you have to remember is to put the html parts inside quotation marks, and to separate them from the php variables with periods. (Actually, in many cases you can just put the php variable inside the html strings, which makes it even easier.)

Of course, the proper way to make the above link in Drupal would be to use Drupal's special link function l(). So that would be:

<?php print t('Location:') . '  ' . l($location, "profile/profile_location/$location") ?>

t() is a simple Drupal function that sends any string within it to be translated, if translation is set up for the site. So ideally, you should put all visible text inside t(), so it will be available for translation.

Jacques Roux's picture
Jacques Roux
Offline
Joined: 17-07-06
Apr 16 2007 11:06

Thanks FF.