SpyJoe Posted July 1, 2011 Share Posted July 1, 2011 Hello, could anyone please help me with the code on how to make a link to another page based on a specific name? I have a page for every name. That name is an attribute and also stored in a database. I want my visitors to be directed to that specific page of a name that is shown on the page that they came from. Because I have so many pages it will take ages to do manually, so I'm using a template and therefore can't link every page manually. I hope I explained clearly. Please ask if you are not sure what I mean. I will be very grateful if someone could help me. Thank you in advance. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 1, 2011 Share Posted July 1, 2011 can you post your code please? (an example of this:) I want my visitors to be directed to that specific page of a name that is shown on the page that they came from How is that name shown? is it a href link? (is the name in the url?) Quote Link to comment Share on other sites More sharing options...
SpyJoe Posted July 1, 2011 Author Share Posted July 1, 2011 That's the thing. I don't have a code. I don't know much about PHP, but I'm trying. I will try to be more specific, sorry. The name is a brand name that is a href LINK to a page that contains all products for that brand. Which is also an attribute and saved in database, as everything is linked together. Below that link is another link. And I want visitors to be redirected to a specific page for that brand name that is shown above, when they click it. Hope this helps. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 1, 2011 Share Posted July 1, 2011 simple solution would be something like: (create dynamic links from database with the page names or ids) <a href="redirector.php?pageName=page1">page1</a> and use a little redirector file to check if the page exists before redirecting that will send them back if the page does not exist. But there are loads of security issues with something like this, because it will allow virtually anyone to write pagenames in the url to open up stuff they shouldn't have access to. either you put all the pages in a specific folder, and only allow them to see pages contained within that folder, or you need to set up a permissions system based on each user (I'm assuming they have to login, might not be the case). Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted July 1, 2011 Share Posted July 1, 2011 Im not sure at all what you are trying to do. And if you don't have a single line of code where to start from. Maybe you start learning from the basics? Or post to freelanceer forums, if you want someone to do something for you. Quote Link to comment Share on other sites More sharing options...
SpyJoe Posted July 1, 2011 Author Share Posted July 1, 2011 I thought this was a simple question. I have done PHP before, but this was years ago, so can't remember much. Thank you, WebStyles, but I don't think that's what I wanted. All I want is for href link to fetch the brandname of the page and direct the visitor to a page for that specific brand that it fetched. I'm sorry if I'm not explaining properly, I don't know how to make it more clear. Visitors can browse pages when they are logged in and out. Security shouldn't be affected by this I think. Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted July 1, 2011 Share Posted July 1, 2011 I really don't get you still. Maybe try put up together some code on your own and test it, and then come post if you encounter problems? Quote Link to comment Share on other sites More sharing options...
SpyJoe Posted July 1, 2011 Author Share Posted July 1, 2011 I really don't know how to explain it more clear. I wouldn't even know where to start with the code. I searched everywhere for something similar, but so far can't find anything. Maybe someone can understand what I mean and post an example. Thank you all for your time. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 1, 2011 Share Posted July 1, 2011 So you need code to fetch the brand name of the page and then pass it on? where are those brand names stored and how are you retrieving them? Quote Link to comment Share on other sites More sharing options...
SpyJoe Posted July 1, 2011 Author Share Posted July 1, 2011 Yes, that is correct. I know that they all are stored in a database, but not sure how they are retrieved. Everything is done automatically by Magento, but I'm trying to customise it a bit. I'm not sure if I'm allowed to post links to other websites here, but couldn't find it in the rules. Here is a page of the website: http://www.legendfootwear.co.uk/hunter-original-black-womens-boots-69786.html Do you see where it says: Brand: Hunter ? (Below the price) And then a bit below it says "Size Guide" Well I want visitors to be directed to a size chart for Hunter from that page. At the moment they are directed to a page which contains all brands' size charts. Because that is a template, I need it all to be done automatically. I hope it is clear what I want to do now. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 1, 2011 Share Posted July 1, 2011 that's pretty easy. All you need to do is grab the brandname then... but if you don't know where it is stored, how are we supposed to know? you need to look at your database, find the name of the table and the field you need (or look at your code in that page, chances are it's already being retrieved) and just add it to the link in the form ?brandname=whteverBrandNameIs, then on your sizes page, just grab the variable, and display only relevant content. Quote Link to comment Share on other sites More sharing options...
SpyJoe Posted July 1, 2011 Author Share Posted July 1, 2011 I've just tried for the last 20 minutes, but can't figure out what code to put. Here is what I have so far: The following code grabs the brand name. $brand = $_product->getResource()->getAttribute('brandname')->getFrontend()->getValue($_product); And here is the link. I don't know what to put here. At the moment the text of the link grabs the brand name and displays it. But the link is to a page where all brands are, no just that one brand. <a href="<?php echo sizeguide.php ?>"><?php echo $brand; ?> Size Guide</a> But how do I direct visitors to a page for that specific brand? Please help me out with the code. How do I grab the variable and display only relevant content? Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 1, 2011 Share Posted July 1, 2011 change this: <a href="<?php echo sizeguide.php ?>"><?php echo $brand; ?> Size Guide</a> for this: <a href="sizeguide.php?brand=<?php echo $brand; ?>">Size Guide</a> then in sizeguide.php grab $_GET['brand'] and create a simple switch() or if() to show only relevant content. Quote Link to comment Share on other sites More sharing options...
SpyJoe Posted July 1, 2011 Author Share Posted July 1, 2011 I'm sorry to be a pain, but how will the if statement work? If brand matches the brand, then display it, if not, don't? That means I have to create if statement for every brand? We have about 40, is that correct? Quote Link to comment Share on other sites More sharing options...
joe92 Posted July 1, 2011 Share Posted July 1, 2011 You need access to your mysql table as WebStyles said. If you have it, you can do something along the lines of: if(isset($_GET['brand'])) { $brand = mysql_real_escape_string(htmlentities($_GET['brand'])); $brand_query = mysql_query("SELECT what_you_need FROM which_table WHERE brand = '$brand'") //then print the data relevant to that specific query which will be specific to the brand the is in the GET } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.