1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

V4.1.x Displaying variables and extra fields NOT already shown on the page

Discussion in 'Modules / Plugins / Modifications' started by seymourjames, Jul 4, 2009.

  1. seymourjames All Hands On Deck

    Try doing what I suggested. Suppress extrafields from being displayed and then use the extrafields plugin within your viewlisting template. It should get you much of the way as far as the display of your listings.
  2. T0m1 Customer

    Hi David,

    Many thanks,

    I am already taking a look at this and will report back with my findings.

    Kindest regards,
  3. T0m1 Customer

    Hi David,

    Ok I can see how I can get this to work :) .

    Slight question though

    I altered the $price call before adding the custom extra field call, to do this
    {if $price == '0.00'} To Give Away {elseif $price == '0.01'} SOLD {else} {$price|format_money}{/if}
    Currently if I want to display ONO etc next to the price I would have to do the following
    {if $price == '0.00'} To Give Away {elseif $price == '0.01'} SOLD {else} {$price|format_money} {get_extra_field id=$view fid=7}{/if}
    This is not practical though and instead what id like to do is (btw ive tested this which obviously gave a smarty error);

    {if get_extra_field id=$view fid=8 =='To Give Away'} To Give Away {else} {$price|format_money} {get_extra_field id=$view fid=7}{/if}
    Now this creates an error as does {if (get_extra_field if=$view fid=8) =='To Give Away'}{/if}
    This bit I know will not be an easy one but I do appreciate all and any help.
    Kindest regards,
  4. seymourjames All Hands On Deck

    Confused and going round in circles here. You said you wanted to display the extrafields in different locations. Now you are trying to apply logical tests on the smarty plugin and it doesn't work as discussed unless you do as Mike was proposing and do it within the smarty plugin.
  5. Lhotch curmudgeon

    Smarty is not as functional as pure PHP. What you will likely have to do is get an extra field and assign it to a new variable in the template and then compare that new variable to 'To Give Away'.

    Something like....

    {assign var='myvar' value=`get_extra_field id=$view fid=8`} <- backtics likely need to be used around value
    {if $myvar == 'To Give Away'} To Give Away {else} {$price|format_money} {get_extra_field id=$view fid=7}{/if}
  6. seymourjames All Hands On Deck

    Again, I do not wish to appear rude or awkward but offer honest advice, really I am trying to help you here as I have been there and got this t-shirt: you are trying to build a $20k website with an investment of $150 and a few hours of effort. It just does not work this way in terms of developing software or any business for that matter. I know; I am constantly in this position lacking many skills but I have learnt to avoid this. If I were you I would look at my goal seriously and scale it back to something you can do with the resources you have. Otherwise you will not be operational and still trying to do widgetry and bend the software to an application it was not designed to handle in a year's time. Everything you are trying to do is going to be complex because you are insisting on trying to make the software fit your goal rather than moderating your goal to fit the software given your constraints.
  7. T0m1 Customer

    Hi Larry,

    Many thanks for this. I have to admit that I keep forgetting about the smarty side of things. I will give your method a go, I have to admit I was playing around with the idea of using {php} tags to insert pure php code into the template, but thats me making things over complex.
    Again many thanks, as I know I can be a bit demanding (as David is pointing out). Speaking of which I hope to make use of your membership module once I have accumulated enough funds to do so.

    I hear exactly what you are saying and please don't take me as an individual who wants and expects everything for nothing. If this was the case I could have opted for something that was free, but instead didnt because 68c had more credability not to mention a few experienced users.

    Im not trying to be rude or ackward either, but I do think that , as an example, displaying an extra field where I want to instead of where the system says I have to, is something thats minor.
    Now having a membership module or function or turning it into an auction site is something I strongly agree with you on in that it is a major change. Even your single checkout page I personally would see as being a big change.

    Anyhow, I do not wish to fall out as it is only a matter of opinions at the end of the day and each one of us is entitled to one of those :) not to mention you have been a great help so far for which I cannot thank you enough.

    Kindest regards and thanks to both of you :),
  8. T0m1 Customer

    Hi Larry,

    Ive tried that bit of code, I placed the first bit into the tpl file (tried at the top before the main table and also within the same cell as the rest of the call).

    The output is the price and the value of extra field id 7, but not the first part of the if statement which it should be.

    I then changed the value just to double check etc but it always only outputs the price and x.field 7. I changed the backticks for ' but this made no difference. I have set the var='mytest' and the if statement calls for $mytest .

    So it looks as though the whole call for {assign... is being ignored or not recognised?

    Kindest regards,

  9. Lhotch curmudgeon

    I wasnt sure if it would work or not. Basically what you asking it to do is take a value returned by a plugin and assign it to another template variable.

    Your best bet, as I think has already been mentioned, would be to copy the plugin, rename it and alter it to do the logic and assign the valus to template vars there.
  10. T0m1 Customer

    Hi Larry,

    I will give this a go and see how everything goes.

    Kindest regards,
  11. seymourjames All Hands On Deck

    I think we are saying the same thing. You need to do the logic from within the smarty plugin. you may even need to make various versions of it for the different cases you have.
  12. KLOUGOON Customer

    Hi Mike,

    Sorry for the belated response but a very sincere thankyou for your reply. I have been offline due to switching servers but have just had a chance to test the code and it works like a charm. I have to say this community is the best I have come across for support and willingness to help others. Thanks again.

    Cheers Kris
  13. T0m1 Customer

    Ok I have to admit I am completely stumped :) lol.

    My problem is that id id need to include a plugin into a plugin as well as a variable to putput the desired result. The problem is obviously that plugins are standalone php files.

    Ive read near enough the entire smarty documentation and the only thing that would come close to allowing me to achieve my result would be the capture tag as originally tried by Kris, which likewise didnt work.

    Im just trying to figure out, how I could assign the output of "get_extra_fields2 id=$view fid=8" to a variable as this then surely should allow me to place the variable inside of a conditional statement within the tpl file.

    Basically, (as looking back im not sure if I came across as well explained as I had imagined? ) what im hoping to achieve is this.

    SelectB 1 has entries "To Give Away" and "Sell"
    SelectB 2 has entries "ONO" "OVNO" "Open to Offers" and "No Offers"

    If a user chooses "To Give Away" from SelectB 1 then output = To Give Away

    else if a user chooses "Sell" from SelectB 1 then output = $price|format_money [value of SelectB 2]

    Anyway Apologies if this wasnt explained to well earlier on (sometimes I tend to skimp over things when im busy on something).

    Kindest regards,
  14. Lhotch curmudgeon

    Im confused as to why you are confused.

    Look at the plugin, what dohees it do? It takes the $view variable which is the id of the ad and the $fid which is the id of the extra field you want, it uses them in a database query and gets the value from the database and assigns it to a PHP variables called $value and then that variable ie returned to the code framework that handles the plugins and then the value of the extra field you requested via {get_extra_fields2 id=$view fid=8} is displayed in the template.

    Lets break this down into plain english and concentrate on just a single extra field.

    What KIND of extra field is it?

    What kind of logic are you looking to perform?

    what do you want the final output to be?
  15. T0m1 Customer

    Hi Larry,

    I guess im seriously confused because ive only just begun learning pure php and this would be bad enough, smarty as we know adds another layer to this and by the looks of it relatively rigid.

    Anyway, in answer to your questions/scenario above.

    What KIND of extra field is it?
    Drop Down List

    What kind of logic are you looking to perform?
    IF elseIf Else statements

    what do you want the final output to be?
    If the == is met then predefined text (or whatever is inside of the If section fo the condition)
    If the != is met, (or the == is not met) then another variable and text (inside of the else section of the condition).

    So to elaborate on your last question, lets please imagine dropdownlist to be a variable $dropdownlist . Ideally this is how id like it to work

    {if $dropdownlist =="Give Away"}

    Free to Good Home

    {elseif $dropdownlist =="Sell"}



    (I know I do not need to use an elseif and could simply have {else} I merely used it as an ideal solution).

    I think this person was trying for exactly the same solution, but unfortunately the thread trailed off? http://www.68classifieds.com/forums.../9281-extra-field-variable-not-evaluated.html

    Many thanks Larry for your help Larry, it is very much appreciated,

    Kindest regards,
  16. Lhotch curmudgeon

    Okay, so once again goto the pluging itself. We see the database query and the result of that query is put into a variablecalled $value so all you need to do is apply your above logic to the variable value and alter it if needed before "returning" it.

    near the bottom of the pluging you have


    return $value
    evaluate and perform logic on $value and proceed as needed...


    if($value =="Give Away"){
    $value "Free to Good Home";
    $value =="Sell"){
    $value '{$price|format_money}';
    I havent tested it and the {$price|format_money} may throw a wrinkle in there because it may not be parsed by smarty.
  17. T0m1 Customer

    Hi Larry,

    That code partly works :)

    The if statements now show 'Free to Good Home' if Give Away is selected and then goes to show the price if not.
    But the output appears as {$price|format_money} on the front end.

    So we are part of the way there :) Now the only thing left to figure out is how to delay the processing of the variable until it is outputted...

    Kindest regards,
  18. Lhotch curmudgeon

    As I eluded to in the last line of my above post, {$price|format_money} is being inserted into the template and is not being parsed so therefor it wont work.

    Honestly what I would probably do is simply set the extra fields to appear in the listing and then just remove the section from the template that displays them. That way they will still be available as smarty vars and you can evaluate them at the template level.
  19. T0m1 Customer

    Indeed you did say that and I would not have thought otherwise.

    You mentioned doing it at template level? How would I do this?

    Many thanks
  20. T0m1 Customer

    Hi Larry,

    Ive been reading over and over what you mentioned above and im trying to understand it.
    I can only (currently) understand it in 2 ways, 1 I create new tpl files and include these into the template?
    Or the other I hide content from google and all other search engines (in effect so viewable by source view but not in browser output) which is a big no no, for me at least.

    Kindest regards,

Share This Page