Search

Hello I am new to Symphony and have some questions.

I have a site that its a car inventory. I need to have an option for each car=product if its sold or not and then show or not a sold banner in its main photo.

I have created a field in each product, actually a pair in technical details of each product. Its "available" and values "yes" or "no".

Is this the best way to do it? Any advices? If yes how will I check the values? I know this is an XSLT based cms but would need some help.

Regards Giorgos

In your template you can do this for example in your template match:

<xsl:if test="available = 'No'>
   <span>Sold</span>
</xsl:if>

Thanks for your answer plenaforma

Just like that? Thats easy to do.

Is the best way to do this check? I mean using a pair.

Is the best way to do this check? I mean using a pair.

What do you mean with pair? A selectbox with two values?

I'd go with a checkbox labelled "Available" with default checked enabled. That will output "Yes" in your datasource as long as the checkbox is checked and "No" in case it's not checked anymore.

Via Ajax Checkbox you can easily edit the status of your products in the entries tabel view.

I attach a screen shot of what I mean Roman. Thanks for suggesting this plugin. It seems it does the same job as the pair but a bit faster.

Same code for checking its value? It looks easier than I thought would be :)

Attachments:
available.png

My example was if you use a checkbox field

OK thought it was for a text field.

I attach a screen shot of what I mean Roman.

Ah... I see - you're using the Meta Keys extension. That's what you meant with "pairs".

Wouldn't use this for a simple Sold/Available-Status-Change as you have to add this field for each entry manually and then actually write "Yes" or "No". Meta Keys is fine for product-details that change may change from product to product, but for a status that every product needs the checkbox-field is the way to go!

Same code for checking its value? It looks easier than I thought would be :)

"Ajax Checkbox" is just an addon to the basic core checkbox field that lets you easily edit checkboxes in the table view.

So the output in the datasource and the Code for checking its value in your template is the same as plenaforma proposed.

Hello again, I am a bit stacked with this and need some help.

I downloaded the Ajax Checkbox plugin, installed it and enabled it. I created a checkbox for each product (image 1) and it works. In every product I see the checkbox option. I tick it for some products try to use it (image 2).

I added the code to my page: Show this if sold out is ticked

But its not working. Am I doing something wrong?

Attachments:
2-product.png and 1.png

The code is: <xsl:if test="sold = '1'">Show this if sold out is ticked</xsl:if>

Your check for sold should be listening for 'yes' or 'no' not '1'. If you have debug devkit installed and you append ?debug to the end of your frontend page.. you should see the full XML output of your datasources for that given page..

Thanks moonoo2, silly mistake but I still see no text after using 'yes'

@giogoskey

Likely an XPATH thing - are you drilling into 'sold' correctly?

What do you see when you simply output sold, i.e. <xsl:value-of select="sold" />? Given the result of your condition I'm going to assume it outputs nothing.

If possible post your XSLT and your XML (as moonoo2 mentioned, you can see this by appending ?debug to your URL, assuming you have Debug Devkit extension installed). Use Pastie or Gist or something though, as it'll likely get mangled in the forum.

Thanks for the replies guys. I am new to Symphony and a bit lost.

I used debug and the xml & xslt are here: https://gist.github.com/geokir/d06fdb2d90204b3adbc6

Hope these help you understand better.

@giorgoskey I think you pasted in the XSLT into both!

Not to worry, we all have to start somewhere and XSLT does have a learning curve. It's a very worthwhile journey, but a journey none the less.

Nathan you are right, I fixed it now. Its a journey indeed and the good news is I am not traveling alone.

Aha, well I think I may have found your main problem. There is no sold node in your XML.

Did you forget to add it to your Data Source output?

By the way, just as a little tip, this kind of structure is a bit easier to work with:

<!-- Main template -->
<xsl:template match="data">
    <xsl:apply-templates select="data-products/entry"/>
</xsl:template>

<!-- Products template -->
<xsl:template match="data-products/entry">
    <xsl:value-of select="name"/>
</xsl:template>

The main change here is I've removed the for-each from the product template. A template is, essentially, a for each, so is redundant in this case. You also don't need the data prefix on the product template, as in this case it's called from within that context. i.e. for the same reason you don't need to preface name with data-products/entry in the products template, you don't need to preface data-products/entry with data in the main template.

Let me know if any of that doesn't make sense!

Took me a while to get my head around the template concept in XSLT, so hopefully this is useful advise!

First of all thanks for your time Nathan, I know its a bit boring to help rookies.

I have created a datasource (in blueprints->data-sources) with the name Sold, see attached but it does not helped at all.

For your suggestions, I will focus on those later. I read about certain things on Symphony nowthat will help me in the 'sold' issue. Cant afford more time for now.

Attachments:
sold.png

But is there also a field in that datasource with the name sold? And what is the value?

You can check if a field exist or check on the value.

<xsl:if test="sold"> <!-- does the field exist -->
  <!-- Do magic here -->
</xsl:if>

or

<xsl:if test="sold = 'Yes'"> <!-- probably a checkbox that is checked -->
  <!-- Do magic here -->
</xsl:if>
<xsl:if test="sold = '1'">Show this if sold out is ticked</xsl:if>

yes I have done this check @plenaforma

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details