Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-08-06 12:13:25

miles
Member
From: Plymouth
Registered: 2008-05-22
Posts: 78
Website

Market Website

Hi TXP

Got a bit of a head scratcher! I am currently building a website for a market – http://plymouthcitymarket.co.uk.s224773.gridserver.com/shops

As you can see there are many duplicate names as some stall owners own more than one “stall space”. So one owner might own stalls 1, 34 and 35 for example.

What would be the best way to amalgamate the articles so it just shows one but has all it’s stall numbers underneath?

I hope that makes sense…

Offline

#2 2018-08-06 12:39:29

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,609
Website

Re: Market Website

You get to do some interesting projects ;-)

As you can see there are many duplicate names as some stall owners own more than one “stall space”. So one owner might own stalls 1, 34 and 35 for example.

How are you currently organising things into articles? It looks like you currently have an article per stall, resulting in the several entries. Maybe there’s a reason for that … like a map or directory with each stall and owner marked, or something like that. If that’s not necessary, it might be easier to organise your articles by stall holders and then put the stall numbers into a custom field as a simple list, e.g. 1, 34, 35. That might be most straightforward.

Alternatively, maybe you can leverage the power of txp:if_different and sort your articles first by shop/owner and then stall number. For each shop entry, you’d only output the shop name and image on the first occurrence of the shop name, but continue to add the stall numbers with each article…

Does that make sense?

A more complex way to relate articles to one another would be to have an article per stall and per shop and then link them to each other via custom fields. glz_custom_fields has a custom scripted field that you could use to make a dropdown allowing you to choose the relevant partner articles from another section. It’s probably a bit overkill and requires editing both linked articles when things change to keep properly up to date.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2018-08-06 13:13:48

miles
Member
From: Plymouth
Registered: 2008-05-22
Posts: 78
Website

Re: Market Website

jakob wrote #313281:

You get to do some interesting projects ;-)

How are you currently organising things into articles? It looks like you currently have an article per stall, resulting in the several entries. Maybe there’s a reason for that … like a map or directory with each stall and owner marked, or something like that. If that’s not necessary, it might be easier to organise your articles by stall holders and then put the stall numbers into a custom field as a simple list, e.g. 1, 34, 35. That might be most straightforward.

Alternatively, maybe you can leverage the power of txp:if_different and sort your articles first by shop/owner and then stall number. For each shop entry, you’d only output the shop name and image on the first occurrence of the shop name, but continue to add the stall numbers with each article…

Does that make sense?

A more complex way to relate articles to one another would be to have an article per stall and per shop and then link them to each other via custom fields. glz_custom_fields has a custom scripted field that you could use to make a dropdown allowing you to choose the relevant partner articles from another section. It’s probably a bit overkill and requires editing both linked articles when things change to keep properly up to date.

Thank you @jakob its really appreciated! Ha yes a very interesting selection!

OK I think I’m halfway there – http://plymouthcitymarket.co.uk.s224773.gridserver.com/shops

So it’s not displaying the images and title but how can I make it not display the whole DIV etc. Sorry it’s monday and im not awake and its probably something simple
<txp:article_custom section="shops" limit="10000" sort="Title asc">



 <div class="col-md-4 col-sm-6 col-xs-12">

<div class="entry">

<txp:permlink class="entry-image">

 <txp:if_different><txp:article_image class="thumbnail" escape="" /> </txp:if_different>
										<div class="dim"></div>
										<i class="icon icon-lg icon-magnifier"></i>
									</txp:permlink>
									<small class="entry-category"><a href="#">Sportswear</a></small>
									<h3 class="entry-title"> <txp:if_different><txp:permlink> <txp:title /> </txp:permlink> </txp:if_different></h3>
									<div class="entry-meta">
										<small class="stars">
											<i class="glyphicon glyphicon-star"></i>
											<i class="glyphicon glyphicon-star"></i>
											<i class="glyphicon glyphicon-star"></i>
											<i class="glyphicon glyphicon-star"></i>
											<i class="glyphicon glyphicon-star disabled"></i>
											<a href="#">4 reviews</a>
										</small>
										<small><a href="#adidas" class="mapplic-link"><i class="icon icon-location-pin"></i>Stall:  <txp:if_different><txp:custom_field name="Stall" /> </txp:if_different></a></small>

									</div>
									<p class="entry-desc"><txp:excerpt /></p>
	  							</div></div>



</txp:article_custom>

Also any ideas how I could possibly display all the stall numbers relating to the Owner/shop once you click on them?

Edited Textile for changing haystack mode to code. — Uli

Last edited by uli (2018-08-06 14:06:09)

Offline

#4 2018-08-06 14:08:26

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,305

Re: Market Website

You’ve some tag errors (opening/closing mismatch). Please correct these first.

how can I make it not display the whole DIV etc.

What exactly?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#5 2018-08-06 14:57:16

miles
Member
From: Plymouth
Registered: 2008-05-22
Posts: 78
Website

Re: Market Website

Revised my code

<txp:article_custom section="shops" limit="10000" sort="Title asc">



 <div class="col-md-4 col-sm-6 col-xs-12">

<div class="entry">

<txp:permlink class="entry-image">

 <txp:if_different><txp:article_image class="thumbnail" escape="" /> </txp:if_different>
										<div class="dim"></div>
										<i class="icon icon-lg icon-magnifier"></i>
									</txp:permlink>

									<h3 class="entry-title"> <txp:if_different><txp:permlink> <txp:title /> </txp:permlink> </txp:if_different></h3>
									<div class="entry-meta">

										<small><a href="#adidas" class="mapplic-link"><i class="icon icon-location-pin"></i>Stall:  <txp:custom_field name="Stall" /> </a></small>

									</div>
									<p class="entry-desc"><txp:excerpt /></p>
	  							</div></div>



</txp:article_custom>

if you have a look at the page http://plymouthcitymarket.co.uk.s224773.gridserver.com/shops it doesn’t show the duplicates but the <div> frames and all the other code remains. is there a way to get rid of this? Wrapping the if_different code around all of it didn’t work

Offline

#6 2018-08-06 15:55:21

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,609
Website

Re: Market Website

Oh, that’s a little more complex. The key with if_different is that the content within it doesn’t change from one article to the next. As txp:article iterates over each article, it skips what was the same as the last article (hence the importance of using the sort attribute so that like articles follow each other) and implements what you don’t place inside if_different.

If it ends up being too complex, you may need to use a trick. I forget exactly how it works. I think it involved doing a simple txp:if_different and setting a variable, then resetting it in the else part. Further down in your code, you check for that variable and then output your code block (or not as the case may be).


TXP Builders – finely-crafted code, design and txp

Offline

#7 2018-08-06 16:18:32

miles
Member
From: Plymouth
Registered: 2008-05-22
Posts: 78
Website

Re: Market Website

Sorry mate you have completely lost me :(

Offline

#8 2018-08-06 16:53:11

etc
Developer
Registered: 2010-11-11
Posts: 5,060
Website GitHub

Re: Market Website

I second to @jacob first proposal, that looks much cleaner:

organise your articles by stall holders and then put the stall numbers into a custom field as a simple list, e.g. 1, 34, 35

Offline

#9 2018-08-06 17:11:49

miles
Member
From: Plymouth
Registered: 2008-05-22
Posts: 78
Website

Re: Market Website

Yeah that would be the easiest option however I need them all to be separate URLs eg

market.com/stall1
market.com/stall2

So I can later point to them from an overlay on a map

Last edited by miles (2018-08-06 17:11:59)

Offline

#10 2018-08-06 17:21:55

etc
Developer
Registered: 2010-11-11
Posts: 5,060
Website GitHub

Re: Market Website

miles wrote #313297:

Yeah that would be the easiest option however I need them all to be separate URLs eg

market.com/stall1
market.com/stall2

So I can later point to them from an overlay on a map

Then I would store stalls coordinates (JSON encoded, say) in some form and retrieve them via JS or etc_query? Looks feasible.

Offline

#11 2018-08-06 18:16:04

miles
Member
From: Plymouth
Registered: 2008-05-22
Posts: 78
Website

Re: Market Website

Thank you both for your help today. With a lot of head scratching I managed to find a solution. I have called all the articles “Stall 1”, “Stall 2” etc and put a custom_field in the article for the name.

Then set the article custom field to only show “Sticky” articles which removes all the duplicates but also keeps the other articles live in the background to link to from the map.

Pheeeww.

Offline

#12 2018-08-06 18:22:12

miles
Member
From: Plymouth
Registered: 2008-05-22
Posts: 78
Website

Re: Market Website

One last question… not sure this is easily possible…

I want to put all the Stall numbers associated with that Owner. The Shop name and Stall numbers are in custom fields.

Is it possible to search for “Sunny Sweets” and if it matches show the stall number?

I want to achieve:

Sunny Sweets
Stalls: 124 , 125

Offline

Board footer

Powered by FluxBB