.htaccess and url rewrite - .htaccess

I know that url_rewrite using .htaccess requires an identifier in the pretty url by which we identify the page/link to load. But, here are a few examples where i can't make out the identifier.
Any ideas how do they do it?
http://techcrunch.com/2014/03/15/julie-ann-horvath-describes-sexism-and-intimidation-behind-her-github-exit/
http://techcrunch.com/2014/03/15/why-we-hate-google-glass-and-all-new-tech/
In both the examples above, the portion http://techcrunch.com/2014/03/15/ is constant. Any ideas on how to do this would be welcome.

There's a lookup based on the "category" and "page name". It uses both "2014/03/15", or the date, as well as the name of the post, "julie-ann-horvath-describes-sexism-and-intimidation-behind-her-github-exit" to fetch the dynamic content. This makes it so you wouldn't really need an ID unless you happen to have 2 posts with the exact same title on the same date. The fetch from the database is a little more complicated with this method, since the title in the URL isn't always going to be the title in the database because the title text needs to be cleaned of special characters and spaces so that it reads nicely within a URL. For example:
/whats-with-all-of-these-titles-in-urls/
Could have a page title: "What's with all of these titles in URLs"
So you can see the ' is removed, the spaces are changed to -'s and everything is made lowercase. CMS's handle this by creating what's called a "slug". The "whats-with-all-of-these-titles-in-urls" title is the "slug" while the real title is "What's with all of these titles in URLs". The slug is stored alongside the title in the database, and is ensured to be unique, at least within each category. This way, the slug is sort of like a numerical ID and is used, along with the category (but not necessarily), to fetch the page content from the database.

Related

How can I crawl but not index web pages in OpenSearchServer?

I'm using OpenSearchServer to provide search functionality on a web site. I want to crawl all pages on the site for links to follow but I want to exclude some pages from the index. I can't work out how to do this.
Specifically the website includes a shop that has its own product search and I am keeping this search for products and categories. The product pages have URLs like http://www.thesite/p/123 so I don't want to include any page like this in the search results. However some product pages reference background info pages and I want these to be included in the search index.
The problem I have is that the filter has no effect on the results - it doesn't filter out the /p/ and /c/ results. If I change the filter by unticking the negative box I get no results so it seems to be either the contents of the field or the filter criteria that is causing the problem.
I've tried adding a negative filter to the default query called search in the Query > Filter tab on the index with url:"http://www.thesite/p/*"
but it seems that wildcards are not supported for query filters although they are supported for Crawler > Exclusion list filters.
I've tried adding a new field called urlField in Schema > Fields and populating it using an analyzer configured using the Whitespace Tokenizer and a regular expression (http://www.thesite/(c|p)/). When I use the Test button it seems to generate two tokens for my test URL http://www.thesite/p/123:
http://www.thesite/p/
p
I'd hoped to be able to use the first one in a Query > Filter to exclude all the shop results and optionally be able to use the p (for product) or c (for category) if I need to search the product pages sometime in the future.
The urlShop field in the schema is set up as follows:
Indexed: yes
Stored: no (because I don't need the field back, just want to be able to filter on it)
TermVector: No
Analyzer: urlShop
Copy of: url
I've added urlFilter:"http://www.thesite/p/" to Query > Filters with the negative box ticked.
This seems to have no effect on the results when I use the default renderer.
To see whether it affects the returned results I unticked the negative box in the query filter I get no results in the default renderer. This leads me to believe that the urlShop field is not being populated but I'm not sure how to check this directly.
I would like to know whether there is an easier way to do this but if my approach makes sense in the context of OpenSearchServer please can you help me identify what's wrong?
The website is running under IIS and OpenSearchServer will be configured on the same server running in Tomcat.
Finally figured this out...
Go to query and hit edit for your configured query. Then go to the filters tab. Add a query filter like this:
urlExact:"http://myurltoexclude*"
Check the "negative" box. Click add.
Now make sure to click "save in the tiny little button on the right hand side. This is the part I missed. The URLS are still in the DB and crawl, but at least they aren't returned in results.

Take data from query string and put into another form value (for both display and posting)

With that said, there is a question that seems to be asked a lot and has answers - but I'm not a programmer 'enough' to understand all the different explanations. I was hoping for something more clear and concise to my very specific example and need.
I have two forms. (I might also add this is being used on Wordpress)
One form is on the first page and will collect age, home value, and debt owed - all in drop down select fields.
The second form is on the next page and will collect other contact information and upon submit - will post all the fields to my CRM.
I have been able to successfully get the data from the first form into a query string on the page of the second form. But try as I might - I just can't figure out how to get the field data from the query string into my field forms. (Both display or pre-populated and as a value ready to be submitted once the rest of the fields are completed.)
Here is an actual query string:
http://example.com/2-form-test-2-of-2/?age=75&value=572%2C500&lien=107%2C500&sendbutton=#.UYSBEKKG2So
I simply need to get "age" - "value" and "lien" from that query string showing in the fields on the 2nd page. Simple is best - even if it's 'hack-ish' as I will most likely just include the code directly on the Wordpress page that includes this form.
One possible solution is to add a piece of javascript that gets fired on page load and:
1) disables form post button
2) populates form fields with values from URL
3) enables form post button
If these values are just suggestions for user, which he could easily change before posting — this should work.
If, on the other hand, these values are internal and unchangeable by user, you should not expose these in editable form and allow user to change those by editing URL or form posting (but including these as read-only page fragments is apparently ok).
This is place for only programmers. To become a programmer, please refer some online resources and ebooks. without knowing basic concepts, you can't understand anything.
even after understanding basics, if you have doubts, you can ask here, providing the code samples you have developed.

Add finding attribute by name in Opencart Admin panel: Catalog - Attributes - Attributes

How to implement Attribute to find his own name in the admin area in Opencart : Products - Attributes - Attributes? Is that there is a separate field and simply by driving into the field and displays the name of the attribute is an attribute, as usual searching for items in the admin by name, but only with attribute
It's hard to understand what you are asking, but if you are trying to use attributes for products then you must first define them at catalog>attributes>attributes.
To List attributes in the Products tab you will need edit these files
admin>view>template>catalog>product_form.tpl
admin>controller>catalog>product.php
If your understanding of PHP or Opencart isn't very strong it will help you to copy data from the attribute.php controller to the product.php controller.
As for the search function, this is something I haven't done before but you could try using the search function on the front of the website as reference.
I recommend working through this as best you can then asking more questions if or when you get stuck.
*Update
Ok so since HTML is your strenth it will be smartest to start from there. Open any of these files (the ones that have the data you need).
admin>view>template>catalog>attribute_form.tpl
admin>view>template>catalog>attribute_group_form.tpl
admin>view>template>catalog>attribute_group_list.tpl
admin>view>template>catalog>attribute_list.tpl
Then work backwards with what you see. The tpl will show variables that look like $attribute, track these back to
admin>controller>catalog>attribute.php
admin>controller>catalog>attribute_group.php
And you will see how all the code is used to pull the data from the model and format it if necessary.

When I add a third segment to my expressionengine url, the exp:channel:entries stops returning results

I'm having an issue where a third "segment" in the url will cause ALL the exp:channel:entries to stop returning results.
Example URLs:
works fine: siteurl.com/index.php/one/two
does not work: siteurl.com/index.php/one/two/three
Example Entry Pull:
{exp:channel:entries channel="my_channel" category="18" sort="asc" search:show_toggle="=SHOW" orderby="sort_order"}
Is this some kind of injection that I am unaware of. I have searched through the documentation, and from what I can tell my specification of a category should overwrite anything in the url. I may be botching it up, but there HAS to be something I can do.?
Something I can modify in the channel module?
Without using the dynamic tag parameter in your Channel Entries tag, ExpressionEngine is expecting a URL Segment Variable to contain the Entry ID or URL Title of your entry.
Since the third URL Segment /index.php/one/two/three isn't a numeric Entry ID or URL Title, your Channel Entries query doesn't contain any information.
By setting dynamic="no" you will ensure that the list is not affected by anything passed in the URL.
Since you've written an extremely specific Channel Entries Query, be sure to add dynamic="no" to your {exp:channel:entries} tag loop to have ExpressionEngine ignore the URL Segments and instead use the parameters you supply:
{exp:channel:entries channel="my_channel" dynamic="no" ...}
...
{/exp:channel:entries}
Furthermore, by adding a simple Conditional Variable to your code, you will be able to see a message when no results are returned:
{exp:channel:entries channel="my_channel" ... }
{if no_results}Sorry, No Results{/if}
...
{/exp:channel:entries}
Grokking the fundamental ExpressionEngine's URL concepts and URL Segments is important to understanding and troubleshooting issues like this.
ExpressionEngine looks at the segments which follow /index.php/ as the following:
the first segment is assumed to be the template group
the next segment is assumed to be the name of a template within that template group
the third segment is assumed to be either the url_title of an entry, or, if the segment is numeric, the entry_id of an entry
So, in your case, EE is looking to load the two template, from the one template group, and then display the entry from the my_channel channel that's in the category with the ID of 18 and has a url_title of three.
Your specification of the category only overwrites any category information in the URL. (e.g., /template_group/template/category/doorstops or /template_group/template/C10 would not affect which entries get displayed in your example).
If you want your {exp:channel:entries} tag to ignore the URL completely (with the exception of pagination), you can add dynamic="off" to your tag parameters.

Sharepoint: Image field with a link

I would like to add a field to a list with displays an Image, but acts as a hyperlink. In other words like the "Hyperlink or Picture" column, but "Hyperlink AND Picture" instead.
Where the two fields you input would be the URL to the image to display, and the URL of the hyperlink.
This must be possible. I notice that the Type (in a document library) column does just that, and also includes the views that are currently being used (in the case of a folder).
Is it possible to duplicate the computed Type field in a document library to read two other fields in the list (which will act as the image url, and the redirect link)? What would the CAML be?
Thanks in advance if anyone could offer any insight.
Arnhem
This can be done but you would need to develop a custom field type. As you have found, SharePoint's default rendering for pictures is without the hyperlink. You need to change how the rendering behaves in Display mode in your own custom field. Check Patterns in Custom Field Rendering for more info.
There are also several examples of creating custom field types on the web. The MSDN articles give a lot of detail about how it all works but don't let that put you off as it's not too tricky.

Resources