Dmitry

titles and aliases

17 posts in this topic

Hello Tronghm! What's up?

Maybe I'm going to ask a difficult question:

I watched a lot of sites about real estate. Titles property, including in your template, all original. Accordingly, the titles also different aliases. And when a new property, you must make sure that the alias titles varied to property is saved and added to the site. But this I know. But unaware agents. And the more users. And if agents or clients want to add a new property to the site. And if they point in the the title field property is also a name that already exists on this site, they have nothing. Since property is an alias that is already available on the site. This will be a nuisance.

Question: Is it possible to find a solution, so that when you add a new property with the same alias, alias new properties remained, such as: "title name-2 -1", " title name-2" and so on ...

How do you question for?

Share this post


Link to post
Share on other sites

Hi Dmitry

Thanks so much for your patience.

This is my solution.

Please open file /administrator/components/com_bt_property/models/property.php.

Find function save

Then find these lines

   	 if (JRequest::getVar('task') == 'save2copy') {
list($title, $alias) = $this->generateNewTitle(0, $data['alias'], $data['title']);
$data['title'] = $title;
$data['alias'] = $alias;
}[/CODE]

then change it to

[CODE]if (empty($data['alias'])) {
$data['alias'] = JApplication::stringURLSafe($data['title']);
}

if (JRequest::getVar('task') == 'save2copy') {
list($title, $alias) = $this->generateNewTitle(0, $data['alias'], $data['title']);
$data['title'] = $title;
$data['alias'] = $alias;
}else{
$db->setQuery('SELECT alias FROM #__bt_properties WHERE alias = ' . $db->quote($data['alias']));
if($db->loadResult()){
list($title, $alias) = $this->generateNewTitle(0, $data['alias'], $data['title']);
$data['title'] = $title;
$data['alias'] = $alias;
}

}[/CODE]

You will get title and alias automatic change when you save a Property with existed name.

It works like "Save and Copy"

Please backup or remember this topic, when you upgrade the component, you need to edit file again.

Because we don't have plan to apply it to BT Property.

Thanks

Dmitry likes this

Share this post


Link to post
Share on other sites

Hello Master Tronghm!

With your decision problem.

If I have a need to edit an already created a property, then there is a problem. When I save the edited property, the system considers the object as an object with an existing title and saves it with a new title and alias.

For example: I need to edit the object "title". After editing the object I had saved and closed. The system stores the object as a "title (2)."

How to fix it?

And another. Is it possible to make while maintaining the object with the same title, the system only changes its alias and the title has not changed?

Thank you master Tronghm!

:)

Share this post


Link to post
Share on other sites

Hi!

I see links to your site:

http://prntscr.com/7a9v5s

6729 - probably is the serial number of a topic

titles-and-aliases / - probably an alias topic

Maybe you can make the preservation of the property titles by analogy with your example?

Thank you master Tro!

Share this post


Link to post
Share on other sites

Haha i got this problem yesterday in testing process.

When i read see you posted new message to this topic, i know you also detected this problem.

I'm sorry for my amateur.

I will find out better solution right know.

Dmitry likes this

Share this post


Link to post
Share on other sites

Hi.

I applied new solution on your site. I changed file /administrator/components/com_bt_proprety/models/property.php.

This solution works follow this.

- Add a new property, if its name existed, the name and alias will be combined with a number

- Edit a property, if you change its name, and new name existed, there is a warning message appear. Of course, the problem we said about is fixed, it still keep old name if you don't change property name.

Dmitry likes this

Share this post


Link to post
Share on other sites

Hi!

Thanks for the help!

Yet it is possible to achieve the result that, in the title of the property is not a sequential number?

I think that it can be used in the next version of the template. After all, your users will use this template to create a real estate portals. When many users from different countries may submit their ads. And there is a high probability that the title of the submitted ads may coincide with the title, which is already available on the site. What do you think?

http://prntscr.com/7efsd1

I think that on your forum, such references are made specifically for such cases:

___________________________

"I see links to your site:

http://prntscr.com/7a9v5s

6729 - probably is the serial number of a topic

titles-and-aliases / - probably an alias topic

Maybe you can make the preservation of the property titles by analogy with your example?"

___________________________

Or I'm wrong?

Share this post


Link to post
Share on other sites

Problem this fix 

 that when editing an old record and save it - it changes the title and alias, i.e. we edit, for example, a "record1" - it becomes "record2" and so on - the link to the old object changes.

need addition to the function "generateNewTitle" in file  /administrator/components/com_bt_property/models/property.php

Share this post


Link to post
Share on other sites

I think this function needs to check the ID of the record in the database. If the entry already exists, you do not need to change the header and alias automatically.

Share this post


Link to post
Share on other sites

solution file /administrator/components/com_bt_property/models/property.php

in sting 259 find 

if (empty($data['alias'])) {
$data['alias'] = JApplication::stringURLSafe($data['title']);
}

if (JRequest::getVar('task') == 'save2copy') {
list($title, $alias) = $this->generateNewTitle(0, $data['alias'], $data['title']);
$data['title'] = $title;
$data['alias'] = $alias;
}else{
$db->setQuery('SELECT alias FROM #__bt_properties WHERE alias = ' . $db->quote($data['alias']));
$id = JRequest::getInt('id');
if($db->loadResult()){
list($title, $alias) = $this->generateNewTitle(0, $data['alias'], $data['title']);
$data['title'] = $title;
$data['alias'] = $alias;
}

and change it 

if (empty($data['alias'])) {
$data['alias'] = JApplication::stringURLSafe($data['title']);
}

if (JRequest::getVar('task') == 'save2copy') {
list($title, $alias) = $this->generateNewTitle(0, $data['alias'], $data['title']);
$data['title'] = $title;
$data['alias'] = $alias;
}else{
$db->setQuery('SELECT alias FROM #__bt_properties WHERE alias = ' . $db->quote($data['alias']));
$id = JRequest::getInt('id');
if($db->loadResult()&& $id==0){
list($title, $alias) = $this->generateNewTitle(0, $data['alias'], $data['title']);
//$data['title'] = $title;
$data['alias'] = $alias;
}

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now