Jump to content

Working around spaces and hyphens in tags meant to associate with a page.


creativejay
 Share

Recommended Posts

EDIT: Not sure why it didn't work the first time I tried it, but creating a tag without the space or hyphen did eventually work. I'll have to use my workaround (since I can't omit the space in the title of the page). Mods are welcome to delete this post or leave it for someone else who might run into the same thing.

I thought I was doing something to make life easier on myself (this is how all tragedies begin).

On a site (live, of course), I had two separate areas where product literature documents were referenced. There is a product literature section, and individual product pages. Before, in each template, I was linking to static URLs for files that were placed on the site via FTP. What usually happened was that I'd upload a file to the Literature section and forget to add it to the product page.

Yesterday I decided that it would be less complicated (and more fool-proof) to use a File upload field in the Product Literature section, with tags that match the titles of the product pages, so that the product's template could pull from the same files. I thought tags would allow me the flexibility to add any tag I might need down the line.

With some fits and starts, I got it working yesterday for two categories of document (I thought). Today, I tried to finish up the task and noticed that two of the products are not pulling any documents at all.

My first instinct, because mysql searches have burned me before, was that the tags "Spectra 500" and "RDS-30" were falling under the search term limits. "Spectra 1000" and "Spectra 1100" work as intended. Reading up in the forums seemed to agree about the search phrase length. I went to the site and did a quick change up of the product page's title and the tags on the document to test, but changing the terms to "Spectra500" and "RDS30" didn't correct it. Later this did start behaving as expected, not sure why I had misleading results from my first attempt.

So I set up and coded a workaround (thinking a multi-Page Select field on the literature page and a corresponding text field for the product pages).

Final code to pull files on pages of template "document" using Page Multiselect from the template of pages of template "product":

		$datasheets = $pages->find("parent=/product-literature/product-data-sheets/,template=document,product_tag=$page");
		$manuals = $pages->find("parent=/product-literature/product-instruction-manuals/,template=document,product_tag=$page");
		if(count($datasheets)) { 
					echo "<div class='col span_2_of_4'>";
						echo "<section class='reports'>";
							echo "<h4 class='section_names'>Available Product Documentation</h4>";
							foreach($datasheets as $datasheet) {
								echo "<div>";
								$datasheetLink = $datasheet->get("254_file")->url;
								echo "<a href='{$datasheetLink}' target='doc_window'><img src='{$config->urls->assets}images/documenticon.png' class='floatleft' alt='{$datasheet->title}'>";
								echo "<p class='file_names'>{$datasheet->headline}</p></a>";
								echo "</div>";	
							}	
						if(count($manuals)) {
							foreach($manuals as $manual) {
								echo "<div>";
									$manualLink = $manual->get("254_file")->url;
									echo "<a href='{$manualLink}' target='doc_window'><img src='{$config->urls->assets}images/documenticon.png' class='floatleft' alt='{$manual->headline}'>";
									echo "<p class='file_names'>{$manual->headline}</p></a>";
								echo "</div>";	
								}
							}
							echo "<br /> <br /></section>";
							echo "</div>";
				} else if(count($manuals)) { 
					echo "<div class='col span_2_of_4'>";
						echo "<section class='reports'>";
							echo "<h4 class='section_names'>Available Product Documentation</h4>";
							foreach($manuals as $manual) {
								echo "<div>";
									$manualLink = $manual->get("254_file")->url;
									echo "<a href='{$manualLink} target='doc_window'><img src='{$config->urls->assets}images/documenticon.png' class='floatleft' alt='{$manual->headline}'>";
									echo "<p class='file_names'>{$manual->headline}</p></a>";
								echo "</div>";	
								}
								echo "<br /> <br /></section>";
							echo "</div>";
				}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...